我是Python的新手,我想知道如何改变一个已经设置好的字符串变量。
例如:
name ='school'
如果我想要使用像 George
、Ben
、Jess
、Katie
等不同的值来替换变量名,我该如何更改呢?
我是Python的新手,我想知道如何改变一个已经设置好的字符串变量。
例如:
name ='school'
如果我想要使用像 George
、Ben
、Jess
、Katie
等不同的值来替换变量名,我该如何更改呢?
=
来为变量分配新值。name = 'school'
print 'the current value of name is:', name
name = 'George'
print 'the current value of name is:', name
结果:
the current value of name is: school
the current value of name is: George