Python3 input and output, python3 Input and Output
Pyhon3 io Input and Output
Myread = open ('e:/cmd.txt ') # open () will return a file object
Mywrite = open ('e:/3/example .txt ', 'w') # The following w will be overwritten if the file exists. If the file does not exist, it will be created.
For myrd in myread: # print cyclically
Print (myrd)
Mywrite. write (myrd)
Myread = open ('e:/cmd.txt ', 'R') # r. open the file in read-only mode. The file pointer is placed at the beginning of the file.
Myread = open ('e:/cmd.txt ', 'rb') # r, which is opened in binary format and used for read-only
Myread = open ('e:/cmd.txt ', 'rb +') # r, which is opened in binary format and used for read-only operations. It is equivalent to adding fields in the text.
Myread. write (B 'sfasfaf') # It must be added. Otherwise, an error is returned.
Myread. seek (5) # Move to the sixth byte of the file
Myread = open ('e:/path. PNG ', 'rb ')
Mywrite = open ('e:/path. PNG ', 'wb') # r, which is opened in binary mode. If the write object exists, it will be overwritten. If the write object does not exist, it will be created.
For I in myread:
Mywrite. write (I)
Myread = open ('e: // path/h.txt ', 'w') # Enter characters in txt
Zs = 'gfgd'
Myread. write (zs)