2025-01-09T14:30:26
This commit is contained in:
22
src0/file_io.py
Executable file
22
src0/file_io.py
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
def read_file(file_name):
|
||||
file = open(file_name, "r")
|
||||
while True:
|
||||
line = file.readline()
|
||||
if not line:
|
||||
break
|
||||
print(line)
|
||||
file.close()
|
||||
|
||||
|
||||
def write_file(file_name):
|
||||
file = open(file_name, "w", encoding="UTF-8")
|
||||
file.write("Hello,\n")
|
||||
file.write("There")
|
||||
file.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
read_file("./file_io.py")
|
||||
write_file("./test.txt")
|
||||
Reference in New Issue
Block a user