1、partition(self, sep): # real signature unknown; restored from __doc__
"""以字符串中的固定字符串拆分成数组
S.partition(sep) -> (head, sep, tail)
Search for the separator sep in S, and return the part before it,
the separator itself, and the part after it. If the separator is not
found, return S and two empty strings.
例如:
i1 = 'xuexipython'
reg = i1.partition('xi')
print (reg)
返回值:('xue', 'xi', 'python')
2、
name_list = ["python","java","php"]
print (name_list[0])
print (name_list[0:2])
print (name_list[2:len(name_list)])
print (name_list[1])
返回值:
python
['python', 'java']
['php']
java
3、append(self, p_object): # real signature unknown; restored from __doc__
在原来的数组里增加字符串
""" L.append(object) -- append object to end """
例如:name_list = ["python","java","php"]
name_list.append("c#")
print (name_list)
返回值:['python', 'java', 'php', 'c#']
4、extend(self, iterable): # real signature unknown; restored from __doc__
在第一个数组后面追加另一个数组
""" L.extend(iterable) -- extend list by appending elements from the iterable """
例如:
name_list = ["python","java","php"]
test = [".net","c++","c"]
name_list.extend(test)
print (name_list)
返回值:['python', 'java', 'php', '.net', 'c++', 'c']
5、index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__
""" 查找功能,没有查到会报错
L.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.
例如:
name_list = ["python","java","php"]
test = name_list.index('ja1va')
print (test)
返回值:1
6、insert(self, index, p_object): # real signature unknown; restored from __doc__
功能:在数组中增加内容 index ,是插入的位置,p_object 插入的内容
""" L.insert(index, object) -- insert object before index """
例如:
name_list = ["python","java","php"]
name_list.insert(1,"c#")
print (name_list)
返回值:['python', 'c#', 'java', 'php']
7、pop(self, index=None): # real signature unknown; restored from __doc__
""去除数组中指定位置的字符串,index 位置",用pop也可以得到指定位置截取的字符串
L.pop([index]) -> item -- remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
例如:
name_list = ["python","java","php"]
a1 = name_list.pop(1)
print (a1)
print (name_list)
返回值:
java
['python', 'php']
8、remove(self, value): # real signature unknown; restored from __doc__
"""从列表里移除索引 是找字符串,功能同pop,区别是 remove 参数是字符,pop是 位置,数字
L.remove(value) -- remove first occurrence of value.
Raises ValueError if the value is not present.
例如:
name_list = ["python","java","php","c#"]
name_list.remove('php')
print (name_list)
返回值:['python', 'java', 'c#']
9、reverse(self): # real signature unknown; restored from __doc__
数组中的数据顺序反转
""" L.reverse() -- reverse *IN PLACE* """
例如:
name_list = ["python","java","php","c#"]
name_list.reverse()
print (name_list)
返回值:['c#', 'php', 'java', 'python']
10、 del
name_list = ["python","java","php","c#"]
##删除列表里的指定元素
del name_list[1]
返回值:['python', 'php', 'c#']
删除列表里的指定元素 从0到1 是小于2
del name_list[0:2]
返回值:['php', 'c#']
元组是不能修改(增删改)
列表和元组的功能一样
元组是() 列表是[]