Advertisement
Felanpro

Working with files

Aug 1st, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. file1 = open("text1.txt", 'w') #Open the file otherwise create if it does not exist. Then the 'w' sets it equal to writing mode.
  2. file1.write("Hello World!\n") #Write into the file!
  3.  
  4. file1.close() #Closes the file.
  5.  
  6. file1 = open("text1.txt", 'r') #Set mode to read 'r'
  7. print(file1.read())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement