首页 > 其他 > 详细

字典映射{ :}

时间:2015-06-29 23:43:38      阅读:265      评论:0      收藏:0      [点我收藏+]

 

技术分享

 

>>> a={host:earth}
>>> a[port]=80
>>> a
{host: earth, port: 80}
>>> a(port)=80
SyntaxError: cant 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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!