- 模块
sys
import sys
print(sys.path)
print(sys.argv)
os
import os
os.system("dir")
cmd_res = os.popen("dir").read()
print(cmd_res)
- pyc
- 数据类型
1.int 在Python中整型数据超过边界后不会报错,类型会变为long(python2.7之前版本),但是在C#中会报错
#32位
type(2**30)
==>int
type(2**31)
==>long
#64位
type(2**62)
==>int
type(2**63)
==>long
2.long 在Python中长整型没有数值的大小
3.float 占8个字节(64位),其中52位表示底,11位表示指数,剩下1位表示符号
4.bool
5.string
- 三元运算
a,b,c = 1,3,5
d = a if a > b else c
==>d = 5
- 进制
- 编码解码
各类型转二进制 encode相反为decode 类似C#(Encoding.Default.GetBytes(str)/Encoding.Defalut.GetString(Bytes)
msg = "陕西西安"
# print(msg.encode()) 因为本是为UTF8所以windows下不会报错但是Linux会
print(msg.encode("utf-8"))
print(msg.encode(encoding="utf-8"))
print(msg.encode(encoding="utf-8").decode(encoding="utf-8"))
======================================================
b'\xe9\x99\x95\xe8\xa5\xbf\xe8\xa5\xbf\xe5\xae\x89'
b'\xe9\x99\x95\xe8\xa5\xbf\xe8\xa5\xbf\xe5\xae\x89'
陕西西安
=======================================================
- List
https://blog.youkuaiyun.com/qq_29756987/article/details/88065298
- Dictionary
https://blog.youkuaiyun.com/qq_29756987/article/details/88552088