//输入
name = input() //直接转义特殊字符串 s3 = r'Hello, "Bart"' //输出
print(100 + 200) //输出带换行 # print String print(''' a b c d''') //输入带提示 name = input('please enter your name: ') //if----else # print absolute value of an integer: # 关键字 or not and # 空值是Python里一个特殊的值,用
None
表示。None
不能理解为0
,因为0
是有意义的,而None
是一个特殊的空值。 a = 100 if a >= 0: print(a) else: print(-a) //编码转换ord('A') = 65
ord('中') =
20013
chr(66) = A //转成Bytes传输
x = b'ABC //字符串对照
%d | 整数 |
%f | 浮点数 |
%s | 字符串 |
%x | 十六进制整数 |
'Hi, %s, you have $%d.' % ('Michael', 1000000)
'Hi, Michael, you have $1000000.'
//数组操作函数http://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014316724772904521142196b74a3f8abf93d8e97c6ee6000
classmates.append('Adam')
classmates.insert(1, 'Jack')
classmates.pop()
classmates.pop(1)
//定义函数def
关键字 //数组函数
reduce
= implode sum = sumfilter
= 筛选sorted
= 排序
//16进制
1.23x109 = 1.23e9
0.000012 = 1.2e-5