Python Class简介1

贡献者:知乎:三生万物【标签:老朽意识】 类别:英文 时间:2020-04-29 13:21:38 收藏数:12 评分:-0.5
返回上页 举报此文章
请选择举报理由:




收藏到我的文章 改错字
Object-oriented Programming (面向对象编程,对象英文名为object)is new fashion and proved to be
plausible in Nowadays Programming world.
In python, we have many data type,like int,float,string,bool,for every data type,we can
correspond method.Here is some example:
[1] a = "Hello human" #We assign the "Hello human"(string type) to variable a.
[2] '''For the object a,as for a string type,we have some method to deal with it.Maybe we want it
[3] appears to be in upper case?'''
[4] print(a.upper())#Guess the result?-->the result is "HELLO HUMAN".
[5] b = 2 #Now we assign the 2(integer type) to variable b.
[6] print(b.upper()) #Guess the result?-->Python would throw out "AttributeError"
AttributeError means b has no attribute called "upper",that is,for the integer type,we have no
method called "upper" to change it case.And obviously, this only apply to string.
See you next time,we would talk about class substantially in the next text.
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
文章热度:
文章难度:
文章质量:
说明:系统根据文章的热度、难度、质量自动认证,已认证的文章将参与打字排名!

本文打字排名TOP20

登录后可见