相关疑难解决方法(0)

无法在python 3.6中安装pickle

我正在尝试运行以下代码: -

import bs4 as bs
import pickle
import requests
import lxml

def save_sp500_tickers():
    resp = requests.get("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")
    soup = bs.BeautifulSoup(resp.text, "html5lib")
    table = soup.find("table", { "class" : "wikitable sortable"}) 
    # print(soup)
    # print(soup.table)

    tickers = []
    for row in table.findAll("tr")[1:]:
        ticker = row.findAll("td")[0].text
        tickers.append(ticker)
    with open("sp500tickers.pickle","wb") as f:
        pickle.dump(tickers, f)
    print(tickers)
#   return tickers
# save_sp500_tickers()
Run Code Online (Sandbox Code Playgroud)

它没有抛出任何错误,但我意识到没有安装pickle模块.我通过pip安装它并得到以下错误: -

D:\py_fin>pip install pickle
Collecting pickle
  Could not find a version that satisfies the requirement pickle (from versions:
 )
No matching distribution found …
Run Code Online (Sandbox Code Playgroud)

python pickle

18
推荐指数
5
解决办法
7万
查看次数

标签 统计

pickle ×1

python ×1