출처 : 반크_독도2023
참고풀이]
import os
arr = os.listdir()
for f in arr:
infile = open(f, "r", encoding="utf-8")
L=[]
for line in infile:
e = line.rstrip() #오른쪽 줄바꿈을 삭제한다.
L.append(line)
infile.close()
outfile= open(f, "w", encoding="utf-8")
L.insert(0,"#define _CRT_SECURE_NO_WARNINGS\n")
for line in L:
outfile.write(line)
outfile.close()
참고풀이 결과]
자료삽입전 내용)
abc.txt]
1
2
3
4
5
6
7
8
9
10
11
12
13
file.py]
import os
arr = os.listdir()
for f in arr:
infile = open(f, "r", encoding="utf-8")
L=[]
for line in infile:
e = line.rstrip() #오른쪽 줄바꿈을 삭제한다.
L.append(line)
infile.close()
outfile= open(f, "w", encoding="utf-8")
L.insert(0,"#define _CRT_SECURE_NO_WARNINGS\n")
for line in L:
outfile.write(line)
outfile.close()
summary.txt]
All's well that ends well.
Bad news travels fast.
Well begun is half done.
Brrds of a feather flock together.
Thank you very mach.
The joy or doeint Python should be in seeing short
Python is executable pseudocode.
자료삽입후 내용)
abc.txt]
#define _CRT_SECURE_NO_WARNINGS
1
2
3
4
5
6
7
8
9
10
11
12
13
file.py]
#define _CRT_SECURE_NO_WARNINGS
import os
arr = os.listdir()
for f in arr:
infile = open(f, "r", encoding="utf-8")
L=[]
for line in infile:
e = line.rstrip() #오른쪽 줄바꿈을 삭제한다.
L.append(line)
infile.close()
outfile= open(f, "w", encoding="utf-8")
L.insert(0,"#define _CRT_SECURE_NO_WARNINGS\n")
for line in L:
outfile.write(line)
outfile.close()
summary.txt]
#define _CRT_SECURE_NO_WARNINGS
All's well that ends well.
Bad news travels fast.
Well begun is half done.
Brrds of a feather flock together.
Thank you very mach.
The joy or doeint Python should be in seeing short
Python is executable pseudocode.
대한민국의 아름다운 영토, 독도의 겨울
'프로그램 > Python 1000제' 카테고리의 다른 글
Python 319제] 두근두근 파이썬(개정판) CHAPTER 11 연습문제 1 p359 (0) | 2024.10.14 |
---|---|
Python 318제] 두근두근 파이썬(개정판) CHAPTER 11 도전문제 p357 (0) | 2024.10.14 |
Python 316제] 두근두근 파이썬(개정판) CHAPTER 11 도전문제(1) p346 (0) | 2024.10.07 |
Python 315제] 두근두근 파이썬(개정판) CHAPTER 10 연습문제 7 p334 (1) | 2024.10.07 |
Python 314제] 두근두근 파이썬(개정판) CHAPTER 10 연습문제 4 p333 (0) | 2024.09.30 |
댓글