callmap = {ts.get_stock_basics: ‘D:/dxw/code/all.csv‘, ts.get_sz50s: ‘D:/dxw/code/50.csv‘, ts.get_hs300s: ‘D:/dxw/code/300.csv‘, ts.get_zz500s: ‘D:/dxw/code/500.csv‘}
def updatecode():
# 更新全部
index = 0
for callfunc in callmap.keys():
df = callfunc()
if index == 0:
df = pd.DataFrame(data=df.index)
else:
df = df[‘code‘]
index += 1
df.to_csv(callmap[callfunc], index=False)
if __name__=="__main__": updatecode()
原文:https://www.cnblogs.com/chengxin1982/p/9161774.html