1.文件操作(2) 代码 f = open('a.txt','a') # "a" 如果源文件不在,会自动创建 f.write('abc') result = f.read() print(result) f.close() # r read 能读,不能写,打开不存在的文件会报错 # w write 能写,不能读 # a add 能写,不会清空以前的内容,不能读…
一 文件操作 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 1.1打开文件读取内容 print(open("sounds","r",encoding="utf-8").read()) Somehow, it seems the love I knew was always the most destructive kind Yesterday when I was young The taste of life was…