易截截图软件、单文件、免安装、纯绿色、仅160KB

PYTHON 一个程序,23行有错,不明白为什么 敬请指教!

Python code:


class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def paint(self, factory):
point = factory.getPoint()
corner = factory.getCorner()
corner.leftUp()
point.line(self.width - 2)
corner.rightUp()
print()
for i in range(self.height - 2):
point.line(self.width)
print()
corner.leftDown()
point.line(self.width - 2);
corner.rightDown();
print()

class Dot:
def line(self, width):
for i in range(width):
print("-",end="")
class Sharp:
def leftUp(self):
print("#", end="")
def rightUp(self):
print("#", end="")
def leftDown(self):
print("#", end="")
def rightDown(self):
print("#", end="")

class DotSharpFactory:
def getPoint(self):
return Dot()
def getCorner(self):
return Sharp()

rect = Rectangle(20, 10)
rect.paint(DotSharpFactory())


23行有错,不明白为什么 敬请指教!

也就是 这一句 print("-",end="") 指在 “=” 这里有问题

觉得python 3下应该不会错。我是用2.6的,print当函数用要


相关问答:

[提问]Python 如何忽略 whitespace 读入

像 C 的 scanf() 那样
比如读入 1 2 3 a b c
每次读入一个
下面这个应该是你想要的吧:
Python code:

>>> k = raw_input()
0 0123 ds dsl sd
>>> k
'0 0123 ds dsl sd'
>>> ......

python 3.x的if语句

>>> x=-1
>>> if x>0:
print ('11')

>>> else:

SyntaxError: invalid syntax (<pyshell#20>, line 1)
网上搜的也是:
>>> x=int(input("Please ent ......

python写文件时出问题

异常代码如下:
write a file error: [Errno 2] No such file or directory: 'C:\x0cile.txt'

Traceback (most recent call last):
  File "C:\Documents and Settings\USER\桌面\复 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号