Menu iconMenu iconPython & SQL Bible
Python & SQL Bible

Chapter 22 - Appendix C: Python Cheat Sheet

File Handling

# Write a file
with open("myfile.txt", "w") as file:
    file.write("Hello, World!")

# Read a file
with open("myfile.txt", "r") as file:
    print(file.read())

File Handling

# Write a file
with open("myfile.txt", "w") as file:
    file.write("Hello, World!")

# Read a file
with open("myfile.txt", "r") as file:
    print(file.read())

File Handling

# Write a file
with open("myfile.txt", "w") as file:
    file.write("Hello, World!")

# Read a file
with open("myfile.txt", "r") as file:
    print(file.read())

File Handling

# Write a file
with open("myfile.txt", "w") as file:
    file.write("Hello, World!")

# Read a file
with open("myfile.txt", "r") as file:
    print(file.read())