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 — code_snippets/Python-Files/Files.py at master · dinesh-byte/code_snippets

Expand file tree

/

Files.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
114 lines (96 loc) · 2.44 KB
/

Files.py

Copy path

File metadata and controls

114 lines (96 loc) · 2.44 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#File Objects
##The Basics:
#f = open("test.txt", "r")
#f = open("test.txt", "w")
#f = open("test.txt", "a")
#f = open("test.txt", "r+")
#print(f.name)
#print(f.mode)
#f.close()
##Reading Files:
#with open("test.txt", "r") as f:
#pass
##Small Files:
#f_contents = f.read()
#print(f_contents)
##Big Files:
#f_contents = f.readlines()
#print(f_contents)
###With the extra lines:
#f_contents = f.readline()
#print(f_contents)
#f_contents = f.readline()
#print(f_contents)
###Without the extra lines:
#f_contents = f.readline()
#print(f_contents, end = '')
#f_contents = f.readline()
#print(f_contents, end = '')
###Iterating through the file:
#for line in f:
#print(line, end = '')
###Going Back....:
#f_contents = f.read()
#print(f_contents, end = '')
###Printing by characters:
#f_contents = f.read(100)
#print(f_contents, end = '')
#f_contents = f.read(100)
#print(f_contents, end = '')
#f_contents = f.read(100)
#print(f_contents, end = '')
###Iterating through small chunks:
#size_to_read = 100
#f_contents = f.read(size_to_read)
#while len(f_contents) > 0:
#print(f_contents)
#f_contents = f.read(size_to_read)
###Iterating through small chunks, with 10 characters:
#size_to_read = 10
#f_contents = f.read(size_to_read)
#print(f_contents, end = '')
#f.seek(0)
#f_contents = f.read(size_to_read)
#print(f_contents, end = '')
#print(f.tell())
#while len(f_contents) > 0:
#print(f_contents, end = '*')
#f_contents = f.read(size_to_read)
#print(f.mode)
#print(f.closed)
#print(f.read())
##Writing Files:
###The Error:
#with open("test.txt", "r") as f:
#f.write("Test")
###Writing Starts:
#with open("test2.txt", "w") as f:
#pass
#f.write("Test")
#f.seek(0)
#f.write("Test")
#f.seek("R")
##Copying Files:
#with open("test.txt", "r") as rf:
#with open("test_copy.txt", "w") as wf:
#for line in rf:
#wf.write(line)
#Copying the/your image:
###The Error
#with open("bronx.jpg", "r") as rf:
#with open("bronx_copy.jpg", "w") as wf:
#for line in rf:
#wf.write(line)
###Copying the image starts, without chunks:
#with open("bronx.jpg", "rb") as rf:
#with open("bronx_copy.jpg", "wb") as wf:
#for line in rf:
#wf.write(line)
###Copying the image with chunks:
#with open("bronx.jpg", "rb") as rf:
#with open("bronx_copy.jpg", "wb") as wf:
#chunk_size = 4096
#rf_chunk = rf.read(chunk_size)
#while len(rf_chunk) > 0:
#wf.write(rf_chunk)
#rf_chunk = rf.read(chunk_size)
You are visitor 01402792 — 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.