Write---> Write string
Writelines---> Write string sequence (sequence: a bunch of strings, separated by commas. For example: dictionaries, lists, tuples)
File_obj.write (Content_obj)
Content_obj + ' \ n ' #me: If you do not add \ n, the content written is not wrapped.
EG1:
File_obj=open (' Test.txt ', ' W ') file exists then open, does not exist then create
File_obj=open (' test.txt ', ' w+ ') ' + ' stands for readable, writable
EG2:
File_obj=open (' Test.txt ', ' W ')
Conta= "Hello"
Contb= "World"
Contc= "Jeapedu.com"
File_obj.write (conta + ' \ n ') #me: If you do not add \ nthe content is not wrapped "= =" Conta= "hello\n"
File_obj.write (contb + ' \ n ')
File_obj.write (CONTC + ' \ n ')
File_obj.close ()
Help (File.writelines)----View assistance
Accept only one parameter, which can be a sequence sequence: list, dictionary, tuple
EG1:
File_obj=open (' Test.txt ', ' W ')
Conta= "hello\n"
contb= "world\n"
Contc= "Jeapedu.com\n"
File_obj.writelines ([CONTA,CONTB,CONTC]) List
File_obj.writelines ((CONTA,CONTB,CONTC)) tuple
File_obj.writelines ({CONTA,CONTB,CONTC}) dictionary
File_obj.close ()
The 24th to write the Python file base