1file = open(“testfile.txt”,”w”)
2
3file.write(“Hello World”)
4file.write(“This is our new text file”)
5file.write(“and this is another line.”)
6file.write(“Why? Because we can.”)
7
8file.close()
1path = "guide/README.txt" # The path of your file should go here
2with open(path, "w") as fil: # Opens the file using 'w' method. See below for list of methods.
3 fil.write("This is the README. It is reccomended that you read it.") # Writes to the file used .write() method
4 fil.close() # Closes file
5'''
6List of methods:
7w* - replace everything with needed text
8r^ - read the file
9a* - adds to file
10x - creates file
11
12* Creates file if the file at that path does not exist
13^ Throws error if file does not exist
14'''
15
1with open("testfile.txt", "w") as f:
2 # "w" - write into file
3 # "r" - read into file
4 # "+" - read and write into file
5 f.write("Hello World")