为了账号安全,请及时绑定邮箱和手机立即绑定

最新回答 / high_flyer_1_叶猴
当子类没有def who(self)函数 此时可以使用父类的def who(self)函数 如果子类本身有就不用了
我就走个流程,唉,西巴

最赞回答 / weixin_宝慕林6309633
result,建一个空的list来储存结果

最赞回答 / 树懒先生QAQ
@是装饰符以原文为例,先定义了一个log()函数。把想要装饰函数factorial()上一行写上 @log,就完成了用log()函数里的内容去“”装饰“”factorial()函数里的内容。通过@装饰符,可以修饰某函数,使其完成自己想要的额外的功能
with open('./text.txt','a+') as f1:
f1.seek(0)
lines=f1.readlines()
f1.seek(2)
for v in lines:
f1.write(v)
import math
x=math.sin(0)
from math import cos
y=cos(0)
print(x,y)
#common.py
def say_hello(name):
print(name+'hell0')
class Student():
def __init__(self,name,gender,score):
self.name,self.gender=name,gender
self.score=score
def __str__(self):
return 'Student:{},{},{}'.format(self.name,self.gender,self.score)
s=Student('xiaowang','girl','98')
print(str(s))
print(isinstance(t,Person))
print(isinstance(t,Student))
print(isinstance(t,Teacher))
print(isinstance(t,object))

最赞回答 / 小白兔cai
定义函数 def __init__(self,   ,  ):函数是写成了   def __int__(self,   ,   ):改写为   def __init__(self,   ,   ):
class Animal():
_count=0
@classmethod
def get_count(cls):
Animal._count+=1
return cls._count
print(Animal.get_count())
print(Animal.get_count())
class Animal(object):
def __init__(self, name, age):
self.name = name
self.age = age


dog = Animal("小黄", 2)
cat = Animal("小花", 3)
print(dog.name,dog.age)
print(cat.name,cat.age)
class Animal():
count=0
def __init__(self,name,age):
self.name=name
self.age=age
Animal.count+=1
dog=Animal('wangwang','2years old')
cat=Animal('mimi','1yeaes old')
print(Animal.count)
课程须知
本课程是Python入门的后续课程 1、掌握Python编程的基础知识 2、掌握Python函数的编写 3、对面向对象编程有所了解更佳
老师告诉你能学到什么?
1、什么是函数式编程 2、Python的函数式编程特点 3、Python的模块 4、Python面向对象编程 5、Python强大的定制类

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消