def get_code(need_file):
'提取股票代码'
wb = load_workbook(need_file)
ws = wb.active
need_list = []
print('正在提取股票代码\n')
for j in range(ws.max_column):
for i in range(ws.max_row):
#提取合法股票代码
content = ws.cell(i+1,j+1).value
try:
content = int(content)
except:
pass
try:
#处理股票代码
content += 1000000
content = str(content)[1:]
if content > '400000': #判断上海(深圳)股票
content = 'sh' + content
else:
content = 'sz' + content
need_list.append(content)
except:
pass
print('预计处理:' + str(len(need_list)) + '\n')
return need_list
股票代码提取函数
猜你喜欢
转载自blog.csdn.net/lee2601/article/details/81084835
今日推荐
周排行