torlee 发表于 2018-8-12 13:08:12

学习Python的一些小笔记

1、在python中 None,False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()都相当于False  代码中经常会有变量是否为None的判断,有三种主要的写法:
  第一种是`if x is None`;
  第二种是`if not x:`;
  第三种是`if not x is None`(这句这样理解更清晰`if not (x is None)`)
  2、Python2.7中的input和raw_input的区别:
  input:用户输入什么类型,就存成什么类型
  raw_input:等于python3的input(用户输入任何值,都存成字符串类型)
  3、
页: [1]
查看完整版本: 学习Python的一些小笔记