一. 添加
1.append(data) 把添加的值直接當(dāng)做一個(gè)元素插入列表當(dāng)中
In [1]: list = ['zi','lie','chuan']
In [2]: list
Out[2]: ['zi', 'lie', 'chuan']
In [3]: list.append('zi')
In [4]: list
Out[4]: ['zi', 'lie', 'chuan', 'zi']
2.extend(data) 會(huì)把添加的值拆開成元素,分別插入到列表當(dāng)中
In [7]: list
Out[7]: ['zi', 'lie', 'chuan', 'zi']
In [8]: list.extend('lie')
In [9]: list
Out[9]: ['zi', 'lie', 'chuan', 'zi', 'l', 'i', 'e']
3.insert(position,data) position 索引
In [10]: lisy = ['zi','lie', 'chuan',]
In [11]: list
Out[11]:['zi', 'lie', 'chuan', 'zi', 'l', 'i', 'e']
In [12]: list.instert(2,'ding')
4.int(x [,base ])
將x轉(zhuǎn)換為一個(gè)整數(shù)
5.long(x [,base ])
將x轉(zhuǎn)換為一個(gè)長整數(shù)
6.float(x )
將x轉(zhuǎn)換到一個(gè)浮點(diǎn)數(shù).
7.complex(real [,imag ])
創(chuàng)建一個(gè)復(fù)數(shù)
8.str(x )
將對象 x 轉(zhuǎn)換為字符串
9.repr(x )
將對象 x 轉(zhuǎn)換為表達(dá)式字符串
10.eval(str )
用來計(jì)算在字符串中的有效Python表達(dá)式,并返回一個(gè)對象
11.tuple(s )
將序列 s 轉(zhuǎn)換為一個(gè)元組
12.list(s )
將序列 s 轉(zhuǎn)換為一個(gè)列表
13.chr(x )>
將一個(gè)整數(shù)轉(zhuǎn)換為一個(gè)字符
14.unichr(x )
將一個(gè)整數(shù)轉(zhuǎn)換為Unicode字符
15.ord(x )
將一個(gè)字符轉(zhuǎn)換為它的整數(shù)值
16.hex(x )
將一個(gè)整數(shù)轉(zhuǎn)換為一個(gè)十六進(jìn)制字符串
17.oct(x )
將一個(gè)整數(shù)轉(zhuǎn)換為一個(gè)八進(jìn)制字符