中文转拼音+动态变量名用法

from pypinyin import lazy_pinyin
a = "电脑数码"
name = "".join(lazy_pinyin(a))
exec(f'{name} = 333')
print(diannaoshuma)


b = "321"
variable = locals()
variable[f"model_{b}"] = {"name": "qiaoer"}

print(variable[f"model_{b}"])
print(model_321)
 

 

posted @ 2022-12-27 14:54  乔儿  阅读(32)  评论(0编辑  收藏  举报