요소 목록 삭제 파이썬

코드 예제

86
0

파이썬 목록에서 요소 제거

myList.remove(item) # Removes first instance of "item" from myList
myList.pop(i) # Removes and returns item at myList[i]
13
0

요소 목록 삭제 파이썬

list.remove(element)
9
0

파이썬 목록에서 요소를 제거하는 방법

# Basic syntax:
my_list.remove(element)

# Note, .remove(element) removes the first matching element it finds in
# 	the list.

# Example usage:
animals = ['cat', 'dog', 'rabbit', 'guinea pig', 'rabbit']
animals.remove('rabbit')
print(animals)
--> ['cat', 'dog', 'guinea pig', 'rabbit'] # Note only 1st instance of
#	rabbit was removed from the list. 

# Note, if you want to remove all instances of an element, convert the
#	list to a set and back to a list, and then run .remove(element)	E.g.:
animals = list(set['cat', 'dog', 'rabbit', 'guinea pig', 'rabbit']))
animals.remove('rabbit')
print(animals)
--> ['cat', 'dog', 'guinea pig']
8
0

파이썬 목록에서 삭제

l = list[1, 2, 3, 4]
l.pop(0) #remove item by index
l.remove(3)#remove item by value
#also buth of the methods returns the item
7
0

목록 파이썬에서 항목을 삭제하는 방법

myList = ['Item', 'Item', 'Delete Me!', 'Item']

del myList[2] # myList now equals ['Item', 'Item', 'Item']
4
0

피토. 목록에서 제거하는 방법

names = ['Boris', 'Steve', 'Phil', 'Archie']
names.pop(0) #removes Boris
names.remove('Steve') #removes Steve

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................