如何定义具有动态输入的python字符串(quasi-)常量?

Dol*_*cci 4 python string constants

例如:

MY_MESSAGE = 'Dear %s, hello.'
# ...
name = "jj"
print MY_MESSAGE % name
Run Code Online (Sandbox Code Playgroud)

python是否具有完成上述代码之类的功能?

mal*_*wan 5

是的,你写的确切方式.你的代码很好.