【发布时间】:2015-03-18 16:33:01
【问题描述】:
当我尝试在 iPython 中应用我在互联网上找到的一些代码时,它出现了一个错误:
TypeError Traceback (most recent call last)
<ipython-input-4-36ec95de9a5d> in <module>()
13 all[i] = r.json()
14
---> 15 cPickle.dump(all, outfile)
TypeError: argument must have 'write' attribute
这是我按顺序完成的:
outfile = "C:\John\Footy Bants\R COMPLAEX MATHS"
然后,我粘贴了以下代码:
import requests, cPickle, shutil, time
all = {}
errorout = open("errors.log", "w")
for i in range(600):
playerurl = "http://fantasy.premierleague.com/web/api/elements/%s/"
r = requests.get(playerurl % i)
# skip non-existent players
if r.status_code != 200: continue
all[i] = r.json()
cPickle.dump(all, outfile)
这是原始文章,可让您了解我想要实现的目标:
【问题讨论】: