我希望能够访问带有点的字典中的密钥str.format().我怎样才能做到这一点?
例如,没有点的键的格式有效:
>>> "{hello}".format(**{ 'hello' : '2' })
'2'
Run Code Online (Sandbox Code Playgroud)
但是当密钥中有一个点时它不会出现:
>>> "{hello.world}".format(**{ 'hello.world' : '2' })
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'hello'
Run Code Online (Sandbox Code Playgroud)