%(xyz)s表示在python中是什么意思

Shi*_*pak 2 python

python中的这些表示是什么以及如何使用.我的猜测是它用于数据验证但从未能够使用它.

%(name)s
%(levelno)s
%(levelname)s
%(pathname)s
%(process)d 
etc..
Run Code Online (Sandbox Code Playgroud)

Fre*_*urk 6

这是使用键的字符串格式:

>>> d = {"answer": 42}
>>> "the answer is %(answer)d" % d
'the answer is 42'
Run Code Online (Sandbox Code Playgroud)