repl.it
@yulin1127/

python-basic-hw14-2

Python

No description

fork
loading
Files
  • main.py
  • demo.txt
  • demo1.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
with open('./demo.txt', 'a') as file_object:
  file_object.write('I like programming. ')
with open('./demo.txt', 'r') as file_object:
  for item in file_object.readlines():
    print(item)

#嘗試使用'w'直接新增檔案
with open('./demo1.txt', 'w') as file_object:
  file_object.write('Python is good!')
with open('./demo1.txt', 'r') as file_object:
  for item in file_object.readlines():
    print(item)