opening a file in python,opening a file,file in python,reading in python,writing in python, 2 amazing way in Reading, Writing and Opening a file in Python effectively, Shopinson, Shopinson

When opening a file in python one needs no hassle simply use code as illustrated below can solve the issue

opening a file in python,opening a file,file in python,reading in python,writing in python, 2 amazing way in Reading, Writing and Opening a file in Python effectively, Shopinson, Shopinson
file in python

Opening a file in python using this simple way

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

How to write 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

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

shopinson-logo-32

©2020 Shopinson: complete guide to programming language

CONTACT US

We're not around right now. But you can send us an email and we'll get back to you, asap.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account