Hướng dẫn python remove list from another list - python xóa danh sách khỏi danh sách khác

Sử dụng
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
0 mà không có biểu hiện lambda

Khi sử dụng các chức năng như

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
1 hoặc
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
0 và tương tự từ
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
3, bạn thường có thể tiết kiệm hiệu suất bằng cách tránh các biểu hiện ____ 14 và sử dụng các chức năng đã có. Các trường hợp của
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
5 và
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
6 xác định một phương pháp 17 17 để sử dụng để kiểm tra ngăn chặn. Người vận hành ____ 18 gọi phương pháp này dưới mui xe, do đó, sử dụng
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
9 có thể được thay thế bằng
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
0. Thông thường sự thay thế này không thực sự đẹp hơn nhưng trong trường hợp cụ thể này, nó cho phép chúng tôi đạt được hiệu suất tốt hơn so với sử dụng biểu hiện ____ 14, khi được sử dụng kết hợp với
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
0:

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = [2, 3, 5, 8]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
0 tạo ra một trình lặp mang lại tất cả các yếu tố trả về
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
4 khi được sử dụng làm đối số cho
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
5.

Các bộ có triển khai nhanh hơn

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
7 vì vậy thậm chí còn tốt hơn là:

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]

Màn biểu diễn

Sử dụng danh sách:

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop

Sử dụng tập hợp:

$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop

Sử dụng Filter [] + Lambda để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..How to remove the elements of a list from another list in Python.

Sử dụng Remove [] để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]

Sử dụng Set [] để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..

Bạn có thể xóa một danh sách khỏi danh sách trong Python không?

Python3

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
7
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
0
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
4
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
8____39

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
0
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
9

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
59

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
6

Đầu ra: & nbsp; 

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]

Sử dụng Filter [] + lambda để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác & nbsp; 

Hàm bộ lọc có thể được sử dụng cùng với Lambda để thực hiện nhiệm vụ này và tạo một danh sách được lọc mới của tất cả các phần tử không có trong danh sách phần tử Xóa.

Python3

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
7
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
0
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
4
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
8____39

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
0
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
9

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
9
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
1
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
4
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
14
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
8

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
6

Đầu ra: & nbsp; 

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]

Sử dụng Filter [] + lambda để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác & nbsp; 

Hàm bộ lọc có thể được sử dụng cùng với Lambda để thực hiện nhiệm vụ này và tạo một danh sách được lọc mới của tất cả các phần tử không có trong danh sách phần tử Xóa.
 

Python3

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
7
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
0
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
4
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
8____39

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
0
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
9

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
9
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
1
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
4
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
14
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
8

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
60
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
61
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
62

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
63
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
64

Sử dụng Remove [] để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác & NBSP;

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
63
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
69

Xóa [] cũng có thể thực hiện nhiệm vụ này nhưng chỉ khi ngoại trừ việc không nhận được các yếu tố cụ thể được xử lý đúng cách. Người ta có thể lặp lại cho tất cả các yếu tố của danh sách đã xóa và xóa các yếu tố đó khỏi danh sách ban đầu. & NBSP;

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
59
 
 

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]

>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
60
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
66
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
67

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2

Python3

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
7
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
0
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
4
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
8____39

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
0
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
9

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
9
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
1
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
4
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
14
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
8

Sử dụng Remove [] để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác & NBSP;

Xóa [] cũng có thể thực hiện nhiệm vụ này nhưng chỉ khi ngoại trừ việc không nhận được các yếu tố cụ thể được xử lý đúng cách. Người ta có thể lặp lại cho tất cả các yếu tố của danh sách đã xóa và xóa các yếu tố đó khỏi danh sách ban đầu. & NBSP;

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
6

Đầu ra: & nbsp; 

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]

Sử dụng Filter [] + lambda để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác & nbsp; to remove all values from a list present in other list

Hàm bộ lọc có thể được sử dụng cùng với Lambda để thực hiện nhiệm vụ này và tạo một danh sách được lọc mới của tất cả các phần tử không có trong danh sách phần tử Xóa.remove the elements of a list from another list in Python.

Python3

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
7
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
0
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
4
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
8____39

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
7
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
0
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
4
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
8____39

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
0
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
9
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
2
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
1
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
6
$ python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
1000000 loops, best of 5: 359 nsec per loop
9

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
2

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
9
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
8

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
64
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
8
>>> from itertools import filterfalse
>>> l1 = [1, 2, 6, 8]
>>> l2 = set[[2, 3, 5, 8]]
>>> list[filterfalse[l2.__contains__, l1]]
[1, 6]
5
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
67

$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
68
$  python3 -m timeit -s "from itertools import filterfalse; l1 = [1,2,6,8]; l2 = set[[2,3,5,8]];" "list[filterfalse[l2.__contains__, l1]]"
500000 loops, best of 5: 522 nsec per loop
69

Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
7
Input:
List one is : [1, 3, 4, 6, 7]
List two is : [3, 6]

Output:
The list after performing the remove operation is : [1, 4, 7]
8
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
3
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
0
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
1
The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
6

Output:

The original list is : [1, 3, 4, 6, 7]
The original list is : [3, 6]
The list after performing remove operation is : [1, 4, 7]
 

Làm thế nào để bạn loại bỏ các mục khỏi danh sách trong một danh sách khác Python?

Sử dụng danh sách hiểu để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..
Sử dụng Filter [] + Lambda để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..
Sử dụng Remove [] để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..
Sử dụng Set [] để xóa tất cả các giá trị khỏi danh sách có trong danh sách khác ..

Bạn có thể xóa một danh sách khỏi danh sách trong Python không?

Phương thức Remove [] xóa phần tử khớp đầu tiên [được truyền dưới dạng đối số] khỏi danh sách.Phương thức pop [] loại bỏ một phần tử tại một chỉ mục nhất định và cũng sẽ trả về mục đã xóa.Bạn cũng có thể sử dụng từ khóa DEL trong Python để xóa một phần tử hoặc lát khỏi danh sách.. The pop[] method removes an element at a given index, and will also return the removed item. You can also use the del keyword in Python to remove an element or slice from a list.

Bạn có thể trừ một danh sách từ một danh sách khác trong Python không?

Sử dụng Numpy để trừ hai Python liệt kê một trong các phương thức mà Numpy cung cấp là phương thức trừ [].Phương thức lấy hai mảng s numpy làm đầu vào và cung cấp các phép trừ yếu tố giữa hai danh sách. One of the methods that numpy provides is the subtract[] method. The method takes two numpy array s as input and provides element-wise subtractions between the two lists.

Làm cách nào để xóa một danh sách khỏi danh sách lồng nhau trong Python?

Loại bỏ các mục khỏi một danh sách lồng nhau.Nếu bạn biết chỉ mục của mục bạn muốn, bạn có thể sử dụng phương thức pop [].Nó sửa đổi danh sách và trả về mục đã xóa.Nếu bạn không cần giá trị bị loại bỏ, hãy sử dụng câu lệnh DEL.use pop[] method. It modifies the list and returns the removed item. If you don't need the removed value, use the del statement.

Bài Viết Liên Quan

Chủ Đề