2.1注释
1.单行注释#,作用于整行
2.’’’ ‘’'或者""" “”"表示区间注释,在这之间的所有内容都会被注释
2.2运算符
1.算术运算符 +-*/ //(整除)%(取余)**(幂)
2.比较运算符> >= < <= == !=(不等于)
3.逻辑运算符and or not
4.位运算符~ & | ^ << >>
5.三元运算符 x,y = 4,5 small = x if x<y else y print(small) #4
6.其他运算符 is(是)not is(不是) in(存在) not in(不存在)
注意:is is not对比的是两个变量的内存地址;== !=对比的是变量值
2.3变量和赋值
1.使用变量之前,需要对其先赋值
2.变量名可以包括字母、数字下划线、但变量名不能以数字开头
3.python变量名是大小写敏感的,foo!=Foo
2.4数据类型与转换
1.int 整型
2.float 浮点型
3.bool 布尔型
注意:python里万物皆对象,只要是对象就有相应的属性attributes和方法methods
获取类型信息
type(object)
isinstance(object,classinfo)
2.5print()函数
print(*1 objects, sep=' ', end='\n', file=sys.stdout, flush=False)