python-文件操作 发表于 2023-05-06 分类于 python python的课后作业 题一: 12f = open("python.txt","a")f.write("python") 题二: 123456import osf = open("python.txt","a")f.write("python")f.close()os.rename("python.txt","python_NEW.txt") 题三: 1234567f = open("python.txt","a")f.write("python")with open("python.txt") as f: file = f.readline() print(file) file1 = file.swapcase() print(file1) 或者 12345678f = open("python.txt","a+")f.write("python")f.seek(0) #将指针归0,也就是复原到第一位,读取是从指针往后读,指针在最后,他后面就没有东西了file = f.readline()print(file)file1 = file.swapcase()print(file1)f.close() 本文作者: liuliuya 本文链接: https://cunko.github.io/2023/05/06/python实现/2023-05-06-python-文件操作/ 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!