V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Yvvon  ›  全部回复第 1 页 / 共 1 页
回复总数  1
2021-01-07 16:31:25 +08:00
回复了 diwuqin 创建的主题 Python 如何使用便利字典后的 index 做为列表名称创建列表呢
a = {'test1': 1, 'test2': 2}

for k, v in a.items():
print(k)
exec(f'{k} = []')
print(test1)
print(test2)
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1299 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 10ms · UTC 17:47 · PVG 01:47 · LAX 10:47 · JFK 13:47
Developed with CodeLauncher
♥ Do have faith in what you're doing.