-
[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()'PYTHON' 카테고리의 다른 글
[PYTHON] math 모듈 (1) 2023.12.01 [PYTHON] strip / lstrip / rstrip (0) 2023.11.30 [PYTHON] 문자열 연산자 / 인덱싱 (0) 2023.11.29 [PYTHON] print() 함수 (1) 2023.11.29 [PYTHON] split / re.split (1) 2023.10.19