Skip to primary content

Phaisarn

Phaisarn

Main menu

  • Home

Post navigation

← Previous Next →

Python Read and Write Text File

Posted on November 14, 2022 by jack

read file

  • How to Read a Text file In Python Effectively (pythontutorial.net)
with open(ipfile, 'r', encoding='utf-8') as f:
    lines = f.readlines()
print(f'{ipfile} = {len(lines)} line(s)')

write file

  • How to Write to Text File in Python (pythontutorial.net)
with open(opfile, 'w', encoding='utf-8') as f:
    f.write('readme\n')
This entry was posted in Python3 by jack. Bookmark the permalink.
Proudly powered by WordPress