1 2 fileName = "myfile.txt" 3 4 # Open or create "myfile.txt"; 5 f = open(fileName, "w") 6 7 f.write("Hello world!") 8 f.close() 9 10 #open and read the file after the appending: 11 f = open(fileName, "r") 12 print(f.read())
py-repoa python playground |