Reading, Writing and Opening a file in Python
Reading, Writing and Opening a file in Python

To a file in one needs no hassle simply using a code as illustrated below can solve the issue

How to open a file Using Python

with open('demofile.txt', 'r') as f:     data = f.()

How to a file Using Python

with open('demofile.txt', 'w') as f:     data = 'the nature of the web'     f.write(data)

the first code snippet opens open() and read .r the file while the second snippet writes .wdata” into the file “demofile.txt

LEAVE A REPLY

Please enter your comment!
Please enter your name here