This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read one line from a file | |
fh = open("input.txt", "r") | |
lines=[] | |
for line in fh.readline(): | |
# read char by char | |
lines.append(line) | |
fh.close() | |
# https://www.guru99.com/reading-and-writing-files-in-python.html#4 | |
# read line by line from a file | |
fl = open("input.txt", "r") | |
fl=f.readlines() | |
for x in fl: | |
print(x) | |
fl.close() | |
# write line by line to a file | |
file = open("testfile.txt", "w") | |
for line in lines: | |
file.write(line) | |
file.close() |
Vere Perrot
資訊人.科技人.行銷人,現為軟體分析師。定位自己為網路觀察家,永遠保持好奇心與熱情,學習跨領域新事物,希望最終能成為一個全方位的人。
GitHub: github.com/perrot | Mail: vereperrot@gmail.com
沒有留言:
張貼留言