GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python Read Text File · toricode/PythonReadTextFile@31e7c89

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • read_all_text.py
  • read_file_loop.py
  • read_readline.py
  • read_unicode.py
  • test.txt
  • test_unicode.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎read_all_text.py‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
f = open('test.txt', 'r')
2+
3+
print(f.read())
4+
5+
f.close()
Collapse file

‎read_file_loop.py‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
f = open('test.txt', 'r')
2+
3+
for line in f:
4+
print(line)
5+
6+
f.close()
Collapse file

‎read_readline.py‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
f = open('test.txt', 'r')
2+
3+
print(f.readline())
4+
print(f.readline())
5+
print(f.readline())
6+
7+
f.close()
Collapse file

‎read_unicode.py‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
f = open('test_unicode.txt', 'r', encoding='utf-8')
2+
3+
for line in f:
4+
print(line)
5+
6+
f.close()
Collapse file

‎test.txt‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Hello! from toricode.com
2+
This file to test Python text file reading.
3+
Happy Coding!
Collapse file

‎test_unicode.txt‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Việt Nam
2+
日本
3+
中国

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.