python读取非标准化文件

tech2024-05-15  80

读取非标准化文件介绍 方法一:pd.read_csv

import pandas as pd df = pd.read_csv(r'C:\Users\lee\Desktop\s.dat',encoding='utf-8',sep=' ')

方法二:with open

t = [] with open(r'C:\Users\lee\Desktop\s.dat') as f: for i in f.readlines(): print(i) t.append(i.rstrip('\n')) pd.Series(t).str.split(expand=True)

最新回复(0)