Write Python Program to Create File and read the contents without read() Method

 

Write Python Program to Create File and read the contents without read() Method

filepath="C:\\Users\\Admin\\Desktop\\Python Notes\\file1.txt"

with open(filepath,'r+') as f:

    f.write(" Hello Friends\n"

           "How are you\n"

           "What is going on")

    for line in f:

        print(line)

Output:

Hello Friends

How are you

What is going on Hello Friends

टिप्पणी पोस्ट करा

0 टिप्पण्या