1. Integer type int
N1 = 4
Ret=n1.bit_length ()
Represents the binary shortest bit number
2. String Type str
TMP = "Wxy"
DIR (TMP) View method
Help (Type (temp)) Detailed method interpretation
Ret=tmp.capitalize () First letter
ret = Tmp.center (20, ' * ') centered
ret = number of occurrences of Tmp.count ("Wxy", 0,20)
ret = tmp.endswith (' y ', 0,4) with what end
Print (Tmp.expandtabs) #将tab键转换成空格
Print (Tmp.find (' x ')) #查找第一的x, find the return position otherwise-1
Print (Tmp.format ()) #格式化字符串
Tmp.strip () #删除空格
Tmp.startswith () #以什么开头
Tmp.replace ()
Tmp.upper ()
Tmp.isalpha () # is ... ?
byte-to-string conversion
b= bytes (a,encoding= ' Utf-8 ') # 3 bytes
c= bytes (a,encoding= ' GBK ') #2个字节
New = str (b,encoding= ' utf-8 ')
#创建字符串或者转换成字符串
x = str ()
3. Boolean type bool
4. List of lists
# li = [11,22,33,44]
# S1 = "Wang Xiuyu" #可for循环就说明可以迭代
# li1 = List (S1) #创建列表, or convert other elements to a list
#列表特有功能
# li = List ()
# li.append () #追加
# li.clear () #清除
# li.extend () #扩展自己, extend to your own interior with another iterative object
# li.reverse () #自己内部元素反转
# Li.insert (1, "") #向指定位置插元素
#公共功能
Li = ["Wxy", "Pig", "cat", {"Wxy": "Pig"}]
Print (Type (li[0])) #索引str
Print (Type (Li[:2])) #切片list
Print (li[3]["WXY"])
5. Tuple tuples
#元组 elements of a tuple element that cannot be modified can be modified
t = (11,22,33)
t1= tuple () #生成或者转换 string list Dictionary
#特有方法
# count
# index
#嵌套
t= (11,22,["Alex", {"K1": "V1"}])
t[2][1][' K2 ']= 123
#元素不可修改
6. Dictionary Dict
#创建
A = {"K1": 123}
b = Dict () #创建或转换
c = Dict (k1=123,k2=456)
Li = [11,22,33]
New_dict = Dict (Enumerate (LI))
Collation: String changes generally generate new content, the original is unchanged, the other dictionaries, tuples, lists will change themselves
All of the data types have methods that exist in the corresponding classes
Fourth Python data type