您是否可以检查我的语法并告诉我为什么调试器会跳过$BookingDetail = json_decode($new_string, true); //true param gets assoc array
语句并跳到try
。
except
上课:
book
class book(object):
def _init_(self, title, author, numPages):
if title is None:
raise ValueError("invalid 'title' argument. please try again")
if author is None:
raise ValueError("invalid 'author' argument. please try again")
if numPages <= 0:
raise ValueError("invalid 'numPages' arguement. please try again")
self.title = title
self.author = author
self.numPages = numPages
上课:
main
答案 0 :(得分:3)
至少有2个错误:
构造函数被称为__init__
,因为jonsharpe已经提到过
您需要str()
来连接整数和字符串。所以你需要修改你的打印功能:
print (b.author + ": " + b.title + "\n" +" Number of page: " + str(b.numPages) )