Answers for "file with python"

2

python files

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
Posted by: Guest on September-09-2021
3

with open as file python

>>> with open('workfile') as f:
...     read_data = f.read()

>>> # We can check that the file has been automatically closed.
>>> f.closed
True
Posted by: Guest on May-31-2020
-3

python file a?

print("ddd")
Posted by: Guest on July-17-2021

Python Answers by Framework

Browse Popular Code Answers by Language