코로나를 끝난 후 오랜만에 온 국비 ^^ (7월 12일)

그래서 난 test9.py 부터 시작한다. 

 

 

< test9.py >

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
print("Python""java")
print("Python""java", sep=" vs ", end="")
# end는 한줄 뭐시기?
print("")
 
scores = {"코딩" : 100"디자인":80"기획"70#사전형태의 데이터 key : values 중광호 이용
 
for title, score in scores.items(): #scores.items(): key : values 값을 다 가져온다. 
    print(title.ljust(5), str(score).rjust(6), sep=":") #ljust 왼쪽으로부터 공간을 얼마사용할건지.
 
for i in range(121):
    print("번호 : " + str(i))
 
번호 001 ~ 020
for i in range(1,21):
    print("번호:" + str(i).zfill(3))  #zfill 자리수 오~ 신기
cs

 

 

 

< test10.py >

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
school_recored = open("score.txt""w", encoding="UTF-8")
print("코딩 : 100"file=school_recored)
print("기획 : 90",file=school_recored)
print("설계 : 80",file=school_recored)
school_recored.close()
 
 
school_recored = open("score.txt","a", encoding="UTF-8")
school_recored.write("DB : 90\n")
school_recored.write("서버 : 80")
school_recored.close() #무조건 close() 해야한다.
 
 
school_recored = open("score.txt""r", encoding="UTF-8")  
#r 로 안바꾸면 io.UnsupportedOperation: not readable 에러남.
#print(school_recored.read()) #전체 읽어고기 ?에러뜸
print(school_recored.readline(), end=""#한줄만 불러오기
print(school_recored.readline(), end=""#한줄만 불러오기
school_recored.close()
 
school_recored = open("score.txt""r", encoding="UTF-8")
while True :    #반복문을 사용해서 한줄이용으로 전체 불러오기
    line = school_recored.readline()
    if not line:
        break
    print(line, end="")
 
 
school_recored = open("score.txt""r", encoding="UTF-8")
lines = school_recored.readlines()
for i in lines:
    print(i, end="")
school_recored.close()
 
cs
 
 
 

 

 

 

< test11.py >

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pickle 데이터 보관 문서를 만듬.
 
import pickle 
 
memo_file = open("memo.pickle""wb")  #write btye
memo = {"과목" : "코딩""점수" :88}
pickle.dump(memo, memo_file)
memo_file.close()
 
memo_file = open("memo.pickle""rb")  #읽기  {'과목': '코딩', '점수': 88}
memo = pickle.load(memo_file)
print(memo)
memo_file.close()
 
with open("memo.pickle""rb"as memo_file:
    print(pickle.load(memo_file))
 
with open("memo.txt""w", encoding="utf-8"as memo_file:
    memo_file.write("메모장입니다.")
 
with open("memo.txt""r", encoding="utf8"as memo_file:
    print(memo_file.read())
 
cs

 

< memo.py >

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
from socket import SocketIO
from tkinter import *
 
window = Tk()
window.title("메모장")
window.geometry("640x480")
 
def new_file():
    print("파일을 새로 만듭니다.")
    
def open_file():
    with open("memo.txt","r",encoding="utf8"as memo:
        txt.delete("1.0",END)
        txt.insert(END,memo.read())
 
def save_file():
    with open("memo.txt","w",encoding="utf8"as memo:
        memo.write(txt.get("1.0",END))
 
menu = Menu(window)
 
menu_f = Menu(menu,tearoff=0)
menu_f.add_command(label="새로 만들기(N)",command=new_file)
menu_f.add_command(label="새 창(W)")
menu_f.add_command(label="열기(O)...",command=open_file)
menu_f.add_command(label="저장(S)",command=save_file)
menu_f.add_command(label="다른 이름으로 저장(A)...")
menu_f.add_separator()
menu_f.add_command(label="페이지 설정(U)...")
menu_f.add_command(label="인쇄(P)...")
menu_f.add_separator()
menu_f.add_command(label="끝내기(X)",command=window.quit)
 
menu_e = Menu(menu,tearoff=0)
menu_e.add_command(label="실행 취소(U)",state="disable")
menu_e.add_separator()
menu_e.add_command(label="잘라내기(T)",state="disable")
menu_e.add_command(label="복사(C)",state="disable")
menu_e.add_command(label="붙여넣기(P)")
menu_e.add_command(label="삭제(L)")
menu_e.add_separator()
menu_e.add_command(label="Bing으로 찾기(S)...",state="disable")
menu_e.add_command(label="찾기(F)...",state="disable")
menu_e.add_command(label="다음 찾기(N)",state="disable")
menu_e.add_command(label="이전 찾기(V)",state="disable")
menu_e.add_command(label="바꾸기(R)...")
menu_e.add_command(label="이동(G)...")
menu_e.add_separator()
menu_e.add_command(label="모두 선택(A)")
menu_e.add_command(label="시간/날짜(D)")
 
menu_o = Menu(menu,tearoff=0)
menu_o.add_checkbutton(label="자동 줄 바꿈(W)")
menu_o.add_command(label="글꼴(F)...")
 
menu_v = Menu(menu,tearoff=0)
 
menu_v_1 = Menu(menu_v,tearoff=0)
menu_v_1.add_radiobutton(label="확대(Ctrl+더하기)")
menu_v_1.add_command(label="축소(Ctrl+빼기)")
menu_v_1.add_command(label="확대하기/축소하기 기본값 복원(Ctrl+0)")
 
 
menu_v.add_cascade(label="확대하기/축소하기", menu=menu_v_1)
menu_v.add_checkbutton(label="상태 표시줄(S)")
 
menu_h = Menu(menu,tearoff=0)
menu_h.add_checkbutton(label="도움말 보기(H)")
menu_h.add_command(label="피드백 보내기(F)")
menu_e.add_separator()
menu_e.add_command(label="메모장 정보(A)")
 
 
menu.add_cascade(label="파일(F)", menu=menu_f)
menu.add_cascade(label="편집(E)", menu=menu_e)
menu.add_cascade(label="서식(O)", menu=menu_o)
menu.add_cascade(label="보기(V)", menu=menu_v)
menu.add_cascade(label="도움말(H)", menu=menu_h)
 
scrollbar = Scrollbar(window)
 
txt = Text(window,yscrollcommand=scrollbar)
txt.pack(fill="both", expand=True, side="left")
 
scrollbar.pack(side="right", fill="y")
scrollbar.config(command=txt.yview)
 
window.config(menu=menu)
window.mainloop()
 
cs

 

 

< image.py >

 

 

 

'풀스택' 카테고리의 다른 글

웹프로그래밍  (0) 2022.08.06

+ Recent posts