摘要: 将一个文件中的内容,在另一个文件中生成. 核心语句: for line in f1: f1中的所有一行 f2.write(line) # 是直接写入f1中出来的每一行,用 .write() 阅读全文
posted @ 2018-10-27 21:29 Jack的逆旅 阅读(298) 评论(0) 推荐(0) 编辑
摘要: f = open("a1.txt", mode="r", encoding="utf-8")content = f.read()print(content)2f2= open(r"G:\课件\day08 文件操作\作业\a1.txt",mode = "r",encoding = "utf-8")pr 阅读全文
posted @ 2018-10-27 16:28 Jack的逆旅 阅读(112) 评论(0) 推荐(0) 编辑
摘要: "字符串"经过strip 之后还是字符串, 而"字符串"经过split 分开后,就变成了一个列表["x","xx","xxx"] 阅读全文
posted @ 2018-10-27 16:09 Jack的逆旅 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 结果: 阅读全文
posted @ 2018-10-27 15:54 Jack的逆旅 阅读(1282) 评论(2) 推荐(0) 编辑
摘要: 全部读取 f = open("喜洋洋",mode= "r",encoding= "utf-8") 方法一: 一次性全部读取f = open("喜洋洋",mode= "r",encoding= "utf-8") print(f.read()) 方法二: 一行一行读取(确定量,用for in迭代) f 阅读全文
posted @ 2018-10-27 15:25 Jack的逆旅 阅读(477) 评论(0) 推荐(0) 编辑