xxxxxxxxxx
with open("filename.txt", "w") as file:
file.write("new line in new/now cleared document")
with open("filename.txt", "a") as file:
file.write("This line is added to the now 2 line document")
with open("filename.txt", "r") as file:
lines = file.readlines() # ["new line in new/now cleared document\n", "This...
xxxxxxxxxx
f = open('filename.txt', 'r') #open for reading (default)
f = open('filename.txt', 'w') #open for writing, truncating the file first
f = open('filename.txt', 'x') #open for exclusive creation, failing if the file already exists
f = open('filename.txt', 'a') #open for writing, appending to the end of the file if it exists
xxxxxxxxxx
***Run error***
Traceback (most recent call last):
File "__tester__.python3", line 5, in <module>
fhandle.write(fcontentes)
NameError: name 'fcontentes' is not defined