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
股票代码提取函数
最新推荐文章于 2024-07-21 16:42:27 发布