ditto But not enough words I hope you can say python Basic rules for file operation Don't be particularly detailed
I learned before c++ Feeling c++ The difficulty of file operation is OK I do not know! python What about?
Basic is OK
The most basic is reading and writing ,c++ Same thing in China , Yes c++ Basic words ,python It's a little bit easier
Reading documents
f = open("1.txt","r") #open Is a built-in function , There are two parameters 1. file name ( With suffix ) 2. Pattern Such as r yes read Pattern , Read mode f.read(5) # Express reading 5 Characters f.close # Close file , and c++ equally
Writing documents
f = open("1.txt","r") #open Is a built-in function , There are two parameters 1. file name ( With suffix ) 2. Pattern Such as w yes write Pattern , Write mode f.write("hello") # Express the hello write file f.close # Close file , and c++ equally
This is the most basic
Others you can search It's all pretty simple
If it helps, please adopt it !