python代码报错IndentationError: unexpected indent
缩进错误:意外缩进
Indentation [ˌɪndenˈteɪʃn] n. 缺口;凹陷;凹痕;行首缩进;行首空格;造成凹陷(或缺口);将行首缩进
indent [ɪnˈdent , ˈɪndent] v. 将(印刷或书写的行)缩进,缩格,缩排 n. 订单;订购
unexpected [ˌʌnɪkˈspektɪd] adj. 出乎意料的;始料不及的
解决办法:
检查缩进,该缩进的缩进,不该缩进的绝对不要缩进!
def cheese_and_crackers(cheese_count, boxes_of_crackers):
print "You have %d cheeses!" % 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 "We can just give the function numbers directly:"
cheese_and_crackers(20,30)//执行的方法一定不能缩进,如果缩进了,结果就是什么都不执行。
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)
print "We can even do math inside too:"
cheese_and_crackers(10 + 20, 5 + 6)
print "And we can combine the two, variables and math:"
cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)