该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
在笨方法学python中有一段代码如下:
def cheese_and_crackers(cheese_count, boxes_of_crackers):
print "You have %d cheese!" % cheese_count
print "You have %d boxes of crackers!" % boxes_of_crackers
print "Man that's enough for a party!"
print "Get a blanket.\n"
print "OR, we can use variables from our script:"
amount_of_cheese = 10
amount_of_crackers = 50
cheese_and_crackers(amount_of_cheese, amount_of_crackers)
这段代码可以运行,但我更改一点后就出现错误
更改后的代码如下:
def cheese_and_crackers(cheese_count, boxes_of_crackers):
print "You have %d cheese!" % cheese_count
print "You have %d boxes of crackers!" % boxes_of_crackers
print "Man that's enough for a party!"
print "Get a blanket.\n"
print "OR, we can use variables from our script:"
amount_of = 10
amount_ob= 50
cheese_and_crackers(amount_of, amount_ob)
运行后出现amount_of未定义这是什么意思?怎么回事?难道不是a=c=10,b=d=50,这不是两个变量之间的相互替换吗?