file = open("file.txt", "w")
file.write("Hello, world!")
file.close()
file = open("file.txt", "w")
file.write("Line 1\n")
file.write("Line 2\n")
file.close()
file = open("file.jpg", "wb")
file.write(binary_data)
file.close()
file = open("file.txt", "a")
file.write("New line\n")
file.close()
with open("file.txt", "w") as file:
file.write("Hello, world!")
file = open("file.txt", "w")
file.write("Hello, world!")
file.flush()