<jupyter_start><jupyter_text>- Write data in a txt file<jupyter_code>f = open('testfile0.txt', 'w')
f.write("hi friends! \nI am exciting to learn!\n")
f.write("this is test file to learn write, append and read using python\n")
f.close()<jupyter_output><empty_output><jupyter_text>- Append data in the txt file<jupyter_code>f = open('testfile0.txt', 'w')
f.write("OK i am adding... appended line\n")
f.close()<jupyter_output><empty_output><jupyter_text>- Read txt file<jupyter_code>f = open('testfile0.txt', 'r')
for line in f:
    print(line)
f.close()
def writeData(dt):
    f1 = open('testfile0.txt', 'a')
    f1.write(dt)
    f1.write('\n')
    f1.close()
writeData("Now OK")
writeData("2.0 3.5")
def redFile():
    f = open('testfile.txt', 'r')
    for line in f:
        print(line)
    f.close()<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup