zoukankan      html  css  js  c++  java
  • 字典映射{ :}

    print(key,aDict[key])相当于名字和内容

    #print语句默认每行添加一个换行符,所以:

    >>> 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'
    >>> 
  • 相关阅读:
    os
    linux常用命令
    css-基础知识
    awk命令详解
    文献综述
    微信JSAPI支付
    SNMP详解
    SNMP进阶
    SNMP协议入门
    SNMP简单网络管理协议
  • 原文地址:https://www.cnblogs.com/hhj187/p/4608900.html
Copyright © 2011-2022 走看看