Home  »  CodeProgrammingSnippetsTechnology   »   How to Write a File in Python

How to Write a File in Python

Posted: March 16, 2022 | by Michael Bright

Write a file in Python code example.

file = open("testfile.txt","w") 

file.write(“Hello World”) 
 
file.close() 

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.