1、remove() (处理列表的函数)
remove() 这个函数是根据列表的内容的删除函数,例子如下所是:
aList = [123, 'a', 'b', 'c', 'd'];
aList.remove('a');
print "List : ", aList;
输出结果为:
List : [123, 'b', 'c', 'd']
2、pop() (处理列表的函数)
pop() 这个函数是根据列表的位置函数,例子如下所是:
aList = [123, 'a', 'b', 'c', 'd'];
aList.pop(0); # 0是序列号
print "List : ", aList;
输出结果为:
List : ['a', 'b', 'c', 'd']
3、replace() (处理字符串的函数)
这个函数可以替换字符换的有关内容
replace(a, b) 将字符串中的a换成b
str = "this is string";
print str.replace("is", "was");
输出结果为:
thwas was string
补充假设字符串str
str.replace(‘ ’, ‘’) #删除字符串中的空格
str.replace(‘ ’, ‘’, 3) #删除字符串中的空格, 最多删除3个