Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 Python 新手,我希望为变量和数组实现动态名称的功能。例如,我想有 10 个这样的数组,具有不同的名称 Array=[0 for i in range(10)]
Array=[0 for i in range(10)]
我同意以前的帖子,这不是一个好主意。不过,这是一种方法
N = 3 code = ','.join(["Array"+str(n) for n in range(N)]) + " = " + ','.join(["[]" for n in range(N)]) exec code