老师好,在哪能看到咱们实操练习中的标准代码呀,想学习对比一下。
a=90 b="a" print(b)
为啥把a的值赋给了b但无法运行呢
老师这是怎么回事呀,为什么就生成新的对象呀。
老师,我的pycharm这个提示是什么意思呀?
class Person: def __init__(self,name): self.name=name def __add__(self,other,others): if isinstance(other,others,Person): return "{0}__{1}__{2}".format(self.name,other.name,others.name) else: return "不能相加" def __mul__(self, other): if isinstance(other,int): return self.name*other else: return "不能相加" p1=Person("高淇") p2=Person("高晓波") p3=Person("焦鹏") print(p1+p2+p3) print(p2*3)
这个代码应该如何修改才能正确啊
a = 123
print(a)
{:*^10d} 表示居中对齐十宽度以*填充,这个d代表啥啊
比如一个二维列表a
a[0] 代表第一行得全部元素
可不可以以这种形式提出第一列元素?
'''' 使用工厂模式、单例模式实现如下需求: (1) 电脑工厂类 ComputerFactory 用于生产电脑 Computer。工厂类使用单例模式,也就是说只能有一个工厂对象。 (2) 工厂类中可以生产各种品牌的电脑:联想、华硕、神舟 (3) 各种品牌的电脑使用继承实现: (4) 父类是 Computer 类,定义了 calculate 方法 (5) 各品牌电脑类需要重写父类的 calculate ''' class Computer: __obj=None __init__flag=True def create_computer(self,brand): if brand=='联想': return Lenovo(Computer) if brand=='华硕': return Asus(Computer) if brand=='神舟': return Hasee(Computer) else: return '未知品牌,无法创建' def calculate(self): print('生产电脑') def __new__(cls, *args, **kwargs): if cls.__obj==None: cls.__obj=object.__init__(cls) return cls.__obj def __init__(self,brand): if self.__init__flag: print('init...') self.__init__flag=False class Lenovo(Computer): def calculate(self): print('生产联想电脑') class Asus(Computer): def calculate(self): print('生产华硕电脑') class Hasee(Computer): def calculate(self): print('生产神舟电脑') factory=Computer() factory2=Computer() x=factory.create_computer('联想')
老师,我这个代码一直报错,看了问答区感觉我代码好像没错啊
while True我这里也不是很明白
a==input('请输入一个字母:')冒号后面是不是可写可不写什么字母的
upper这里指?
老师你好,为什么在我输入的数字超过100后第二次输入数字却没有反应
老师这是哪一个步骤出现问题了 语句完全没问题的吧
int函数把字符串变为整数的运行问题。
定义对象a="24元",
输出a,结果为'24元'
使用int函数对a进行整数处理却有问题,求解答。
>>> a="24元" >>> a '24元' >>> int(a)
for i in range(num+1): t.penup() t.goto(x1[0][0],x1[0][1]-30*i) t.pendown() t.goto(x1[1][0],x1[1][1]-30*i) for i in range(num+1): t.penup() t.goto(y1[0][0]+30*i,y1[0][1]) t.pendown() t.goto(y1[1][0]+30*i,y1[1][1])
老师,这俩个for循环是啥意思呀,有点不理解(画棋盘)
老师,为什么print不转化成字符串就会报错?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637