写文件
# f= open('D:\桌面\py\hello.txt','w')#确定文件的位置,并确定读写 # f.write('hello,world')#写入的内容 # f.close()#关闭文件
j
w 写入内容
a+ 追加写入内容
读文件
# f=open('D:\桌面\py\hello.txt','r')#确定文件的位置,并确定读写 # print(f.read())#调用read()方法可以一次读取文件的全部内容 # f.close()#关闭文件
r 读取内容