FIle
-
[PYTHON] 파일 쓰기, 읽기PYTHON 2023. 10. 19. 13:27
hello_script = """ hello \thi \thihi hello world """ #파일 쓰기 hello_file = open("hello.txt", "w") shell_scrip = "\n".join(line.lstrip(' ') for line in shell_scrip.splitlines()) #왼쪽 공백 제거 hello_file.write(hello_script) hello_file.close() #파일 읽기 hello_file = open("hello.txt", "r") hello_file.read().strip() hello_file.close()