假设我们有一些像这样的代码:
placehold = "6"
string1 = "this is string one and %s" % placehold
print string1
placehold = "7"
print string1
Run Code Online (Sandbox Code Playgroud)
运行时,两个 print 语句都返回,就好像 placehold 始终为 6。但是,就在第二条语句运行之前,placehold 更改为 7,那么为什么它没有动态反映在字符串中呢?
另外,您能建议一种使字符串返回 7 的方法吗?
谢谢