我需要'person%s' % x
等于'textvar%s' % x
,但我不想将'person%s' % x
设置为people[int('%s' % x)]
。你知道吗
global people
people = ['Zach : 10', 'Danielle : 10']
global num
num = len(people)
for x in range(0, numDebt):
globals()['textvar%s' % x] = people[int('%s' % x)]
globals()['person%s' % x] = textvar%i % x
根据Martijn Pieters的评论,一本字典确实起到了这个作用;事实上非常好
相关问题 更多 >
编程相关推荐