append()在列表的末尾添加一个元素
Test_list = [1, 2, ‘3’ ,‘丛林小青蛙’, ‘草丛小白兔’, ‘blue cat’, ‘999’]
Test_list.append(‘append小盆友’)
print(Test_list)
#[1, 2, ‘3’, ‘丛林小青蛙’, ‘草丛小白兔’, ‘blue cat’, ‘999’, ‘append小盆友’]
clear()删除列表中的所有元素
Clear_list = [‘将要’, ‘被’, ‘吃掉的’, ‘猪’]
Clear_list.clear()
print(Clear_list, ‘,看,猪被吃掉了’)
#[] ,看,猪被吃掉了
copy()返回列表的副本
Copy_list = [‘waiting’, ‘to’, ‘copy’]
Copy_list_01 = Copy_list.copy()
print(Copy_list)
print(‘模仿别人的Copy_list_01:’, Copy_list_01)
#[‘waiting’, ‘to’, ‘copy’]
#模仿别人的Copy_list_01: [‘waiting’, ‘to’, ‘copy’]
count()返回具有指定值的元素数量。
Guess_list = [‘猜’, ‘我的’, ‘元素长度’, ‘啊’, ‘啊’]
list_length = Guess_list.count(‘啊’)
print(‘啊的那个的长度是:’, list_length)
#啊的那个的长度是: 2