随笔分类 - python
摘要:点击查看代码 """ 可视化结果 """ import matplotlib.pyplot as plt f=open('/home/yanhua/Desktop/ncc-600_0.0004.txt','r') data=f.read().splitlines() f.close() test=d
阅读全文
摘要:一、os.listdir() 语法:os.listdir(path) 函数用途:输出路径下所有文件的文件名,以列表的形式返回指定文件夹的下所有内容,不管是文件还是文件夹 二、os.path.splitext() 语法:os.path.splitext(文件名) 函数用途:将文件名和扩展名分开,就是以
阅读全文
摘要:shutil.copy('来源文件','目标地址')
阅读全文
摘要:python的readlines()方法用于读取所有行,且返回值是一个列表,换行符包含在字符串中。 f = open("a.txt","r") results = f.readlines() 使用字符串的splitlines()函数方法 f = open("a.txt","r") results =
阅读全文
摘要:文件打开的两种方式: 点击查看代码 f = open("data.txt","r") #设置文件对象 f.close() #关闭文件 with open('data.txt',"r") as f: #设置文件对象 str = f.read() #可以是随便对文件的操作 读文件操作如下: 点击查看代码
阅读全文