python的文件操作方法汇总

luntanwailian 18 0 PDF 2020-12-30 07:12:39

文件的读操作 示例: print("->文件句柄的获取,读操作:") f = open('无题','r',encoding='utf8') d = f.read() f.close() print(d) print('->例二:') f = open('无题','r',encoding='utf8') e = f.read(9) f.close() print(e) #python3中,文件中一个中英文都占位1 运行结果: 复制代码 ->文件句柄的获取,读操作: 昨夜星辰昨夜风 画楼西畔桂堂东 身无彩凤双飞翼 心有灵犀一点通 ->例二: 昨夜星辰昨夜风 画 文件

用户评论
请输入评论内容
评分:
暂无评论