Ran*_*Rag 12
你有这样的调用profile.keys()和profile.items().他们是方法.
如果省略括号,则实际上不会调用该函数.而是获得对函数对象的引用.
>>> mydict = {'foo':'bar'}
>>> mydict.keys
<built-in method keys of dict object at 0x01982540>
>>> mydict.keys()
['foo']
>>>
Run Code Online (Sandbox Code Playgroud)
If you want to iterate over keys:
for x in profile.keys():
print x
Run Code Online (Sandbox Code Playgroud)
或价值观
for x in profile.values():
print x
Run Code Online (Sandbox Code Playgroud)
或键值对:
for x, y in profile.items():
print x, y
Run Code Online (Sandbox Code Playgroud)
或者只是分配给一个变量以供以后使用
x = profile.items()
Run Code Online (Sandbox Code Playgroud)
ETC。
| 归档时间: |
|
| 查看次数: |
8155 次 |
| 最近记录: |