码迷,mamicode.com
首页 > 其他好文 > 详细

字典映射{ :}

时间:2015-06-29 23:46:47      阅读:381      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!