python动态调用函数

时间:2022-02-26 09:08:03
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():
# 更新全部
for callfunc in callmap.keys():
df = callfunc()
if callmap[callfunc].find('all') >= :
df = pd.DataFrame(data=df.index)
else:
df = pd.DataFrame(df['code'], columns=['code']) df.to_csv(callmap[callfunc], index=False)
if __name__=="__main__": updatecode()