0
我有以下定義的函數,並試圖找出如何從csv中拉出值並將它們放到URL的「theid」部分。從一個'創建'的URL拉數據
def get_csv_column(csv_fname, col, **kwargs):
with open(csv_fname, 'rb') as inf:
incsv = csv.reader(inf, **kwargs)
column = [row[col] for row in incsv]
return column
def withid (theid):
""""""
global cache
dupe = False
theurl = "{0}{1}{2}".format(OMDBURL, "?i=", theid)
response = urllib2.urlopen(theurl)
movdata = json.load(response)
for mov in cache:
if movdata[MKEY[1]] == mov[MKEY[1]]:
dupe = True
if not dupe:
cache.append(movdata)
return movdata
###I thought this loop below could reach in, pull the data and add a 5 second delay after each request
with open('step3_desired_output.txt','w') as step3:
for column in withid:
step3.write(movdata)
time.sleep(5)
這似乎不工作,我是一個但失去了如何進行。
延續的
啊,還以爲ü簽字......非常感謝您的幫助......這正是我需要的這一步。 – kegewe
@kegewe:我做到了;我回來了,看到你已經留下了四條評論和一個幾乎相同的問題。 –
對不起,我在這裏有點新 – kegewe