函数传参,及多线程处理问题, NameError: name 'i' is not defined,求各位大神帮忙找找问题呀,谢谢

2017-07-17 11:59:31 +08:00
 miao009
#%%
def splist(l,s):
lst = []
lst =[l[i:i+s] for i in range(len(l)) if i%s == 0]
return lst
#%%

def hansu (i,tokenlst):
dict03 = {}

for token in splist(tokenlst,1800)[i] :
try:
url02 = '''http://xxxxxx?token=%s&type=app_application'''%token
resq = json.loads(requests.get(url02).text)['obj']
df02 = pd.DataFrame(resq)
dict03[token] = {'APP 个数':len(df02)}
df05 = pd.DataFrame(dict03).T
df05.to_excel('D:/维度 0716/APP 个数.xlsx')
except:
continue
return df05


threads = []
for j in range(len(splist(tokenlst,1800))):
t = threading.Thread(target=hansu,args=(j,tokenlst))
threads.append(t)
t.start()
for t in threads:
t.join()
2074 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/375870

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX