标签:
>>> a={‘host‘:‘earth‘} >>> a[‘port‘]=80 >>> a {‘host‘: ‘earth‘, ‘port‘: 80} >>> a(‘port‘)=80 SyntaxError: can‘t assign to function call >>> a{‘port‘}=80 SyntaxError: invalid syntax >>> a[‘port‘]=80 >>> a {‘host‘: ‘earth‘, ‘port‘: 80} >>> a.keys() dict_keys([‘host‘, ‘port‘]) >>> a keys() SyntaxError: invalid syntax >>> keys() Traceback (most recent call last): File "<pyshell#158>", line 1, in <module> keys() NameError: name ‘keys‘ is not defined >>> a.keys( ) dict_keys([‘host‘, ‘port‘]) >>> a.key() Traceback (most recent call last): File "<pyshell#160>", line 1, in <module> a.key() AttributeError: ‘dict‘ object has no attribute ‘key‘ >>>
标签:
原文地址:http://www.cnblogs.com/hhj187/p/4608900.html