老师 我没有理解到数组长度8与“name"的散列值为什么是取后3位而不是取2位?
请问老师,左移动运算符,怎么实现高位丢弃,Python不对数字没有范围要求吗,那不就丢弃不了了吗
???
老师,为什么我的会报错?
关于组合,如果同一部门两个员工属于同一个组 这种情况可以使用组合实现吗
老师你好,我的代码运行输出的结果不是赋值123
请问第三行print("start:"+str(n))中是用符号+而不是,
这块外层循环和内层循环的逻辑,和执行顺序讲的有点不清楚
老师您好!就是完成这个作业,画布置会画一个矩形,画第二个的是不是的吧import.turtle再输入一遍吗?全部弄完只输入一遍turtle.done()吗?我刚才试了一下直接输入 turtle .penup() turtle.goto(180,0) turtle.penown() turtle.forward(300)画布上只出现一个矩形图,哪个线没看见
import turtle turtle.showturtle() turtle.done() 苹果系统导入turtle模块之后找不到showturtle,其他done,goto那些都不行
老师,为什么我的输出结果没有end:1?
class Student: company="sxt" def __init__(self,name): self.name=name @classmethod def printdel(cls): print(cls.company) @staticmethod def add(a,b): print(a+b) return a+b Student.printdel()
老师,为什么我这个代码运行后会报错:
Traceback (most recent call last):
File "D:\python exec\py.01\py.面向对象\mypy05.py", line 16, in <module>
Student.printdel()
AttributeError: type object 'Student' has no attribute 'printdel'
class CarFactory: __obj = None __init_flag = True def __new__(cls, *args, **kwargs): if cls.__obj == None: cls.__obj = object return cls.__obj def __init__(self): if CarFactory.__init_flag: CarFactory.__init_flag = False def createCar(self,brand): if brand=="奔驰": return Benz() elif brand=="宝马": return BMW() elif brand=="比亚迪": return BYD() else: return("未知品牌,无法创建") class Benz: pass class BMW: pass class BYD: pass factory=CarFactory() factory2=CarFactory() print(id(factory)) print(id(factory2)) c1=factory.createCar("奔驰") c2=factory.createCar("宝马") print(c1) print(c2)
高洪老师在演示中没有报错,为什么我的报错了,说type object 'object' has no attribute 'createCar'
子类重写父类的方法是不改变原父类方法,只在重写的子类生效吗?还是原父类的方法也被更改了?
class Person: def __init__(self,name): self.name=name def __add__(self,other): if isinstance(other,Person): return "{0}--{1}".format(self.name,other.name)#这里为什么用other.name else: return "不是同类,不能相加" def __mul__(self,other): if isinstance(other,int): return self.name*other else: return "不是同类,不能相乘" p1=Person("高洪") p2=Person("高希希") x=p1+p2 print(x) print(p1*3)
老师,改写add方法中,return中第二个参数为什么用other.name?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637