怎么读取D盘中的text文件的数据(数据是一行行的),如下面截图;
然后转换成['000001.SZ','000009.SZ','000039.SZ']这种形式,并输出到本地
f = open('a.txt', 'r', encoding='utf-8')
d = f.read().split('\n')
f.close()
print(d)
_=[]
with open(r'D:/text.txt', 'r', encoding='utf-8') as f:
txt=f.readline().replace('\n','')
while txt:
_.append(txt)
txt = f.readline().replace('\n','')
print(_)