zoukankan      html  css  js  c++  java
  • Python学习(三)

    if语句

    • 格式:
      • if 条件:
      •     语句
      • elif 条件:
      •     语句
      • else:
      •     语句
    • and 且
    • or 或
    • not
      • if 'apple' not in fruits:
      •     print('')
    • 布尔表达式 True  False

    字典

    • dict = {'name': 'huluwa' , 'age': 1}
    • print(dict['name'])
    • 删除键对值 del dict['name']
    • 遍历字典
      • for key , value in dict.items():
        • print(' Key: ' + key)
        • print('Value: ' + str(value))  #因为有的value是非字符类型,故用str()转换,key和value变量名可以随意设置
    • 遍历字典所有键
      • for k in dict.keys()
      • for k in dict         #两式效果相同
    • 使用集合set过滤重复值
      • for v in set(dict.values)
  • 相关阅读:
    工作的开端五
    工作的开端一
    工作的开端四
    工作的开端三
    工作的开端二
    springMVC基础配置
    3
    2
    文件操作Utils方法1
    解压zip并解析excel
  • 原文地址:https://www.cnblogs.com/cnyws/p/14890475.html
Copyright © 2011-2022 走看看