Python里读取txt文件的方法有很多,但numpy读取字符串比较困难,这时可以考虑使用csv库,读取txt文件中的每一行文本。
代码
data = []
with open('*******.txt', 'rt') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
data.append(row)
Python里读取txt文件的方法有很多,但numpy读取字符串比较困难,这时可以考虑使用csv库,读取txt文件中的每一行文本。
代码
data = []
with open('*******.txt', 'rt') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
data.append(row)