我想从两种方式引用数组到新变量中。然后,当我从引用数组中移出索引时,它也会从原始的双向数组中删除。我没想到这一点,想知道为什么吗?另外,在从原来的双向数组保留所有项目的同时,如何从引用数组中移出项目?
import requests
from bs4 import BeautifulSoup
url = 'https://www.newegg.com/Product/ProductList.aspx?Submit=ENE&DEPA=0&Order=BESTMATCH&Description=graphics+card&N=-1&isNodeId=1'
res = requests.get(url, headers = {'User-Agent': 'Mozilla/5.0'})
soup = BeautifulSoup(res.content, 'lxml')
items = [item['title'] for item in soup.select('.item-brand img[title]')]
print(items)