Python - 065 : Perform write on a file in python

Pubblicato il: 23 luglio 2023
sul canale di: The Digital Folks
96
2

The write() method:
This function inserts the string into the text file on a single line.

Based on the file we have created above, the below line of code will insert the string into the created text file, which is "myfile.txt.”


file.write("Hello There\n")
The writelines() method:
This function inserts multiple strings at the same time. A list of string elements is created, and each string is then added to the text file.

Using the previously created file above, the below line of code will insert the string into the created text file, which is "myfile.txt.”

f.writelines(["Hello World ", "You are welcome to Fcc\n"])


In questa pagina del sito puoi guardare il video online Python - 065 : Perform write on a file in python della durata di ore minuti seconda in buona qualità , che l'utente ha caricato The Digital Folks 23 luglio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 96 volte e gli è piaciuto 2 spettatori. Buona visione!