本文主要是介绍[Python]:IndentationError: unexpected indent,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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_countprint "You have %d boxes of crackers!" % boxes_of_crackersprint "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 = 50cheese_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)
这篇关于[Python]:IndentationError: unexpected indent的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!