文件读取及存储
文件读取
1 pandas.read_csv
SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。sep : str , default',' 指定分隔符。如果不指定参数,则会尝试使用逗号分隔。
header=None 表明数据中是否存在列名,如果在第0行,则为0,如果没有,则为None。default= 0;
1 df = pd.read_csv('D:\\thethirdTencentalgcom\\testA\\test_sample.dat',sep='\t',header=None)
文件存储
1 format()
形如str.format()
,format中的内容用于代替str中的 {} 和
:
当读取的文件较大需要分开存储时可用此函数对其编号
1 >>>"{} {}".format("hello", "world") # 不设置指定位置,按默认顺序 2 'hello world' 3 4 >>> "{0} {1}".format("hello", "world") # 设置指定位置 5 'hello world' 6 7 >>> "{1} {0} {1}".format("hello", "world") # 设置指定位置 8 'world hello world'
参考:https://blog.csdn.net/zhchs2012/article/details/84328742

更多精彩