Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ryanxhl
code_snippets
提交
20f20de8
C
code_snippets
项目概览
Ryanxhl
/
code_snippets
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code_snippets
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
20f20de8
编写于
7月 30, 2018
作者:
C
Coder44
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added Code Snippets
上级
3e23f3ec
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
132 addition
and
0 deletion
+132
-0
Python-Files/Files.py
Python-Files/Files.py
+114
-0
Python-Files/README.txt
Python-Files/README.txt
+8
-0
Python-Files/test.txt
Python-Files/test.txt
+10
-0
未找到文件。
Python-Files/Files.py
0 → 100644
浏览文件 @
20f20de8
#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)
Python-Files/README.txt
0 → 100644
浏览文件 @
20f20de8
The Files.py contains all the code snippets shown in
the tutorial. To explicitly use them all through out the video tutorial, make sure to uncomment
them to use it.
In the image section, make sure to use your own image.
Video Link: https://www.youtube.com/watch?v=Uh2ebFW8OYM&t=1295s
Python-Files/test.txt
0 → 100644
浏览文件 @
20f20de8
1) This is a test file
2) With multiple lines of data...
3) Third line
4) Fourth line
5) Fifth line
6) Sixth line
7) Seventh line
8) Eighth line
9) Ninth line
10) Tenth line
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录