カテゴリー:
エラー
閲覧数:236 配信日:2017-05-25 17:10
修正前
return(r.width, r.height,r.area())
from bottle import route
# Rectという名前のクラスを定義する。
class Rect:
# インスタンスが作成された直後に呼び出される特殊なメソッドを定義する。
def __init__(self, width, height):
self.width = width # width属性に値を格納する。
self.height = height # height属性に値を格納する。
# 面積を計算するメソッドを定義する。
def area(self):
return self.width * self.height
@route('/')
def index():
r = Rect(100, 20)
return(r.width, r.height,r.area()) # 100 20 2000と表示される。
修正後
return(str(r.width), str(r.height), str(r.area()))
from bottle import route
# Rectという名前のクラスを定義する。
class Rect:
# インスタンスが作成された直後に呼び出される特殊なメソッドを定義する。
def __init__(self, width, height):
self.width = width # width属性に値を格納する。
self.height = height # height属性に値を格納する。
# 面積を計算するメソッドを定義する。
def area(self):
return self.width * self.height
@route('/')
def index():
r = Rect(100, 20)
return(str(r.width), str(r.height), str(r.area())) # 100 20 2000と表示される。