0
for i in range(14):
    self.root.get_screen('order_screen').ids.timestamp+f".{i}.title" = self.date + ' ' + self.time

预期应该是这样的:

self.root.get_screen('order_screen').ids.timestamp0.title = "current time value"
self.root.get_screen('order_screen').ids.timestamp1.title = "current time value"
self.root.get_screen('order_screen').ids.timestamp'...'.title = "current time value"
self.root.get_screen('order_screen').ids.timestamp13.title = "current time value"

如何用带有 for-range 循环的单行替换上述样板代码?

提供的使用“+”连接运算符的代码会抛出错误,因为它没有被解释为方法访问运算符。

4

0 回答 0