[고1 프로그래밍] 09 - (2)

2023. 9. 13. 14:41·고1/프로그래밍
file = open("newfile.txt","w",encoding="utf-8")
for i in range(1,11):
    data = "%d번째 입니다\n" % i
    file.write(data) # data를 파일객체(file)에 써라
file.close()

file = open("newfile.txt","r",encoding="utf-8")
line = file.readline()
print(line)
file.close()

file = open("newfile.txt", "r", encoding="utf-8")
while True:
    line = file.readline()
    if not line:
        break
    print(line, end="")
file.close()

file = open("newfile.txt", "r", encoding="utf-8")
lines = file.readlines()
for line in lines:
    print(line, end="")
file.close()

file = open("newfile.txt", "r", encoding="utf-8")
data = file.read()
print(data)
file.close()

file = open("newfile.txt", "a", encoding="utf-8")
for i in range(11, 21):
    data = "%d번째 줄입니다.\n" %i
    file.write(data)
file.close()

file2 = open("newfile2.txt", "w", encoding="utf-8")
file2.write("Life is too short, you need python.")
file2.close()

with open("newfile3.txt", "w", encoding="utf-8") as file3:
    file3.write("파이썬 공부 열심히 하면 훌륭한 사람이 될거예요.")
for i in range(1, 51):
    with open(str(i) + "주차.txt", "w", encoding="utf8") as report_file:
        report_file.write("- {0} 주차 주간보고 -".format(i))
        report_file.write("\n부서 : ")
        report_file.write("\n이름 : ")
        report_file.write("\n업무 요약 : ")
저작자표시 (새창열림)

'고1 > 프로그래밍' 카테고리의 다른 글

[고1 프로그래밍] 09 - (5)  (0) 2023.09.25
[고1 프로그래밍] 09 - (4)  (0) 2023.09.20
[고1 프로그래밍] 09 - (3)  (0) 2023.09.18
[고1 프로그래밍] 09 - (1)  (0) 2023.09.11
[고1 프로그래밍] 08 - (1)  (0) 2023.08.30
'고1/프로그래밍' 카테고리의 다른 글
  • [고1 프로그래밍] 09 - (4)
  • [고1 프로그래밍] 09 - (3)
  • [고1 프로그래밍] 09 - (1)
  • [고1 프로그래밍] 08 - (1)
백학도령
백학도령
  • 백학도령
    백학도령
  • 전체
    오늘
    어제
  • 공지사항

    • 유용한 청년
    • 목록 (110)
      • 웹디자인개발기능사 (5)
      • 티스토리 (1)
      • 고3 (5)
        • 응용 프로그래밍 (2)
        • 데이터베이스 (1)
        • 성공적인 직업생활 (1)
        • 비즈니스 영어 (1)
      • 고2 (40)
        • 문학 (4)
        • 수학 (4)
        • 인공지능 수학 (1)
        • 통합사회 (4)
        • 영어 (6)
        • 한국사 (6)
        • 일본어 (4)
        • 응용 프로그래밍 (3)
        • 게임 프로그래밍 (4)
        • 자료 구조 (4)
      • 고1 (59)
        • 국어 (4)
        • 수학 (4)
        • 과학 (4)
        • 영어 (4)
        • 프로그래밍 (16)
        • 화면구현 (11)
        • 게임엔진 (15)
        • 인공지능 (1)
  • hELLO· Designed By정상우.v4.10.3
백학도령
[고1 프로그래밍] 09 - (2)
상단으로

티스토리툴바