下面是python里面的字符串转化为变量的3种方法,如果大家还有方法,请指出,多谢!
var = "This is a string"
varName = 'var'
s= locals()[varName]
s2=vars()[varName]
print(s)
print(s2)
下面是python里面的字符串转化为变量的3种方法,如果大家还有方法,请指出,多谢!
var = "This is a string"
varName = 'var'
s= locals()[varName]
s2=vars()[varName]
print(s)
print(s2)
本文标题:字符串转换为变量的几种办法
本文链接:https://www.haomeiwen.com/subject/wtkmsftx.html
网友评论