个人比较喜欢用第三种方法
var = "This is a string"
varName = 'var'
s= locals()[varName]
s2=vars()[varName]
print s
print s2
print eval(varName)
个人比较喜欢用第三种方法
var = "This is a string"
varName = 'var'
s= locals()[varName]
s2=vars()[varName]
print s
print s2
print eval(varName)
#字符串变为变量a="res"globals()[a]=1print(res)
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M