This repository was archived by the owner on Dec 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ν΄λμ€ λ©μλμ μ€νν± λ©μλ
2
+
3
+ class Person (object ):
4
+
5
+ kind = 'human'
6
+
7
+ def __init__ (self ):
8
+ self .x = 100
9
+
10
+ # μ€λΈμ νΈλ₯Ό μμ¨λ λ©μλλ₯Ό κ°μ Έμ¬ μ μλ€.
11
+ @classmethod
12
+ def what_is_your_kind (cls ):
13
+ return cls .kind
14
+ # def what_is_your_kind(self):
15
+ #return self.kind
16
+
17
+ # μ΄λ κ² μ°λ κ²λ κ°λ₯νλ€.
18
+ @staticmethod
19
+ def about (year ):
20
+ print ('about human {}' .format (year ))
21
+
22
+ # μ€λΈμ νΈκ° μΆλ ₯
23
+ a = Person ()
24
+ print (a )
25
+ print (a .kind )
26
+ print (a .x )
27
+ print (a .what_is_your_kind ())
28
+
29
+ print ('######################################' )
30
+
31
+ # ν΄λμ€κ° μΆλ ₯
32
+ b = Person
33
+ print (b )
34
+ print (b .kind )
35
+ # print(b.x)
36
+ print (b .what_is_your_kind ())
37
+
38
+ print ('######################################' )
39
+
40
+ # μ€λΈμ νΈ μμ΄
41
+ print (Person .kind )
42
+ print (Person .what_is_your_kind ())
43
+ Person .about (1999 )
Original file line number Diff line number Diff line change
1
+ # νΉμ λ©μλλ₯Ό μ¬μ©ν©λλ€.
2
+
3
+ class Word (object ):
4
+
5
+ # μ΄ μμ±μκ° νΉμ λ©μλλ€.
6
+ def __init__ (self , text ):
7
+ self .text = text
8
+
9
+ # λ¬Έμμ΄μ μ½μ΄μμ λ μΆλ ₯νλ νΉμ λ©μλμ΄λ€.
10
+ def __str__ (self ):
11
+ return 'Word!!!!'
12
+
13
+ # κΈΈμ΄λ₯Ό κ°μ Έμ€λ νΉμ λ©μλμ΄λ€.
14
+ def __len__ (self ):
15
+ return len (self .text )
16
+
17
+ # λνλ νΉμ λ©μλμ΄λ€.
18
+ def __add__ (self , word ):
19
+ return self .text .lower () + word .text .lower ()
20
+
21
+ # μ
λ ₯λ κ°μ΄ μλ‘ κ°μκ°λ₯Ό νλ¨νλ νΉμ λ©μλμ΄λ€.
22
+ def __eq__ (self , word ):
23
+ return self .text .lower () == word .text .lower ()
24
+
25
+ w = Word ('test' )
26
+ w2 = Word ('##############' )
27
+ w3 = Word ('test' )
28
+ print (w )
29
+ print (len (w ))
30
+ print (w + w2 )
31
+ print (w == w2 )
32
+ print (w == w3 )
You canβt perform that action at this time.
0 commit comments