请尽快使用Pro版接口:https://waditu.com/document/2
stock2.py
# coding: utf-8 import os, sys import pandas as pd import tushare as ts if len(sys.argv) ==2: code = sys.argv[1] else: print('usage: python stock2.py stockcode ') sys.exit(1) if len(code) !=6: print('stock code length: 6') sys.exit(2) if code < '600000': code = code +'.SZ' else: code = code +'.SH' # 初始化pro接口 pro = ts.pro_api('your token') # help(ts.get_k_data) 了解参数 df = pro.daily(ts_code=code, start='20160101') df.to_csv(code+'.txt') # 数据基本统计量 df['close'].describe().to_csv(code+'.tsv', sep='\t') # 取样 2019年以后的数据 df = df[df['trade_date'] >'20190101'] df.to_csv(code+'.csv') # 取样 2019年以后的收盘价 基本统计 df['close'].describe().to_csv(code+'.spj', sep='\t')