Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
21 lines (17 loc) · 525 Bytes

File metadata and controls

21 lines (17 loc) · 525 Bytes
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
"""
应用: 文件的备份copy
"""
old_file = open("Test.txt", "r")
result = old_file.readlines()
print(result)
# for循环开始进行copy写入
new_file = open("Test(附件).txt", "w")
for line in result:
new_file.write(line)
old_file.close()
new_file.close()
"""
上面的例子直接readlines(),并不是完美的copy方法
如果文件过大,一点点的读取写入,内存问题,防止电脑变卡
在读取的时候,可以按行读取或者按照公司的字节读取(2014)
"""
Morty Proxy This is a proxified and sanitized view of the page, visit original site.