[Operation] python file

--- --- restore content begins

f = open ( "d: \\ a100.txt") # with a single slash error. OSError: [Errno 22] Invalid argument
reached, f.read = CC () 
Print (CC) # ha
f.close ()
------------------------------- ----------------------------------------------
f = open ( "d: \\ a100.txt", mode = "w") # delete the original text and then write
 
f = open ( "d: \\ a100.txt", mode = "a") # additional writing

f.write ( "cavalry infantry")

----------------------------------------------------------------------------------

Open = F ( "D: \\ a100.txt", MODE = "R & lt +") 
f.write ( "ha")
f.close ()
# ha cavalry soldiers, the cavalry infantry infantry cavalry infantry infantry cavalry cavalry infantry, the front cover.

---------------------------------------
f=open("d:\\a100.txt",mode="r+")
f.read()
f.write("哈哈哈")
f.close()
Ha ha ha soldiers cavalry infantry infantry cavalry Cavalry Cavalry Infantry Infantry Infantry Cavalry Ha ha ha 
the first reading, the cursor will go to the final, so the final write.
f.seek (0), the cursor moves to the front

 

Guess you like

Origin www.cnblogs.com/yang30293316/p/11261178.html