我有这样的代码(示例):
count = 3
def test(count):
a = 1
while a <= count:
global list + str(a)
list + str(a) = []
print(a)
a += 1
test(count)
print(list1)
print(list2)
print(list3)
如何在函数中创建动态全局变量(列表)?我需要使我的代码工作,需要访问变量(列表):"list1","list2"one_answers"list3"从函数外部。
谢谢
谢谢大家。我使用了以下代码:
count = 3
urls = {}
def test(count):
a = 1
while a <= count:
urls[a] = 'test'
a += 1
test(count)
print(urls)