Python class 3
(我会分开两部分讨论实例这个概念)
Last time we have attach to some superficial knowledge of Object-oriented Programming in python,
that we defined a class and some attribute inside. As what we discussed in previous snippet, python
has some built-in data type and some of them have it's own method--for example, "I am a string".
upper() are used to converting this string into uppercase, that is it would be "I AM A STRING".And
we could also find that we could not apply it to int type like 5.upper() would be treated as
exception which clash with rule of python.
But last time we remain a conundrum and let us do a quick recap:
Class Human:
def __init__(self,name):
self.name = name
self.run = "False"
def running(self):
self.run = "True"
human1 = Human("Peter")
print(human1.run)#Would print out "False"
human1.running()
print(human1.run)#Would print out "True"
Through the code above,we define a class Human, and two method inside, one is "__init__",another
is "running",while both of them has a "self" as the first parameter.Why we do that?
Last time we have attach to some superficial knowledge of Object-oriented Programming in python,
that we defined a class and some attribute inside. As what we discussed in previous snippet, python
has some built-in data type and some of them have it's own method--for example, "I am a string".
upper() are used to converting this string into uppercase, that is it would be "I AM A STRING".And
we could also find that we could not apply it to int type like 5.upper() would be treated as
exception which clash with rule of python.
But last time we remain a conundrum and let us do a quick recap:
Class Human:
def __init__(self,name):
self.name = name
self.run = "False"
def running(self):
self.run = "True"
human1 = Human("Peter")
print(human1.run)#Would print out "False"
human1.running()
print(human1.run)#Would print out "True"
Through the code above,we define a class Human, and two method inside, one is "__init__",another
is "running",while both of them has a "self" as the first parameter.Why we do that?
Last one:Python class 4
Next one:《The Significance of Failure》
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
Hot degree:★☆☆☆☆
Difficulty:★★★☆☆
quality:☆☆☆☆☆
Description: the system according to the heat, the difficulty, the quality of automatic certification, the certification of the article will be involved in typing!
This paper typing ranking TOP20
- 1格物致知 06-14 10:15365 KPM
- 2xiaofeijiuji... 06-14 10:33240 KPM
- 3paner 06-14 14:42237 KPM
- 4沐玥 06-14 01:52222 KPM
- 5covid19 06-13 22:05220 KPM
- 6游客13675955... 06-14 02:54211 KPM
- 7pythondecora... 06-13 21:46206 KPM
- 8游客13647083... 06-14 11:27201 KPM
- 9游客13677284... 06-14 16:00181 KPM
- 10游客13604531... 06-14 09:57176 KPM
- 11hcs 06-14 13:17172 KPM
- 12游客13611961... 06-14 20:14164 KPM
- 13SmileMach... 06-13 21:59161 KPM
- 14游客13674583... 06-14 12:47161 KPM
- 15游客13362156... 06-13 23:05156 KPM
- 16自然即存在 06-14 13:03156 KPM
- 17游客13497792... 06-16 10:03154 KPM
- 18游客12972239... 06-14 11:47143 KPM
- 19草根时代 06-14 10:47142 KPM
- 20游客13673500... 06-14 12:02142 KPM
用户更多文章推荐
- 我们的认识如何构建2021-12-22
- Arch?2021-07-12
- o_O2021-07-12
- 哥林多前书13章4-8节(圣经)2021-01-30
- Nucleus(细胞核)2021-01-29
- A sea dirge(poem)2020-08-22
- 英文小说段落(3)2020-08-22
- 英文小说片段(2)2020-08-19
- 递归以及其利弊(1)2020-08-18
- 英文小说段落(1)2020-08-18
- 10 Bible Verses on Salvation 12020-08-18
- 奥古斯丁忏悔录【卷二】12020-07-05
- 床前明月光2020-07-02
- Python list method(1)2020-06-26
- Python class 52020-06-15
- Python class 42020-06-13
- Python class简介22020-04-29
- Python Class简介12020-04-29
- 圣经-歌罗西书-3章(1-17节)(英文)2020-04-20
- 圣经-传道书-11章-英文2020-04-17