标签:write ade 读取 open wan numpy encoding nes imp
import numpy as np import pandas as pd
#创建一个txt文件 # ft=open("temp04.txt","a+",encoding="utf-8")
# ft.writelines("id?name?grade"+"\n") # ft.writelines("1?tanghao?88"+"\n")
# ft.writelines("2?lisi?59"+"\n")
# ft.writelines("3?wangwu?95"+"\n")
# ft.writelines("4?张三?12"+"\n")
# ft.writelines("5?唐唐?99"+"\n") # ft.close()
# 读取txt里的文件,与读csv文件差不多一样
df1_r=pd.read_table(open("temp04.txt",encoding="utf-8"),sep="?")
print(df1_r)
""" id name grade
0 1 tanghao
88 1 2 lisi
59 2 3 wangwu
95 3 4 张三
12 4 5 唐唐 99 """
标签:write ade 读取 open wan numpy encoding nes imp
原文地址:https://www.cnblogs.com/yiyea/p/11441826.html