python列表 python必背函數(shù)?
python必背函數(shù)?1. 函數(shù):Print string2。函數(shù):計算字符長度3。Format(12.3654,“6.2F”/“0.3%”)函數(shù):實現(xiàn)格式化輸出4。函數(shù):query object T
python必背函數(shù)?
1. 函數(shù):Print string
2。函數(shù):計算字符長度
3。Format(12.3654,“6.2F”/“0.3%”)函數(shù):實現(xiàn)格式化輸出
4。函數(shù):query object Type
5。Int()函數(shù),float()函數(shù),str()函數(shù):類型轉(zhuǎn)換
6。Import()函數(shù):Import library
7。3**4:3的4次方
8。打開()。Write()函數(shù):Write file
9 def function Name(參數(shù)):自定義函數(shù)
10隨機.randint()函數(shù):生成隨機數(shù)
11。函數(shù)的作用是:返回一個從1到100的列表并打印
12。Lower()函數(shù):將數(shù)據(jù)改為小寫
13。函數(shù):將數(shù)據(jù)改為大寫
14。啟動開關功能:判斷是否用s
15打開。函數(shù):在3-1位置前插入數(shù)據(jù)
16 List()函數(shù):將字符串轉(zhuǎn)換為List
17。Del list[2]函數(shù):刪除第二個數(shù)據(jù)元素
18。Remove(“ha”)函數(shù):刪除原始數(shù)據(jù)中的“ha”元素
19。Eval:evaluate Python expression
在python的函數(shù)中,如何將列表list的一部分作為函數(shù)的參數(shù)?
python中如何計算列表中元素的個數(shù)?
描述len()方法返回的列表元素數(shù)。Syntax len()方法語法:len(list)parameter list——要計算的元素列表。返回值返回列表元素的數(shù)目。示例下面的示例演示len()函數(shù)的用法:#!/usr/bin/pythonlist1,List2=[123,“XYZ”,“Zara”],[456,“ABC”]print“first list length:”,len(LIST1)print“second list length:”,以上示例的輸出結(jié)果如下:first list length:3 second LSIT length:2