标签:practice rom nbsp 显示 where and error: als erro
碰到的主要问题:
这是python在告诉你:Hi,老兄,你的文件里格式不对了,可能是tab和空格没对齐的问题,你需要检查下tab和空格了”。
可以通过编辑器Notepad进行进一步查看:视图-显示符号-显示空格与制表符
要求是tab和空格数目都一致的。
1 #-*- coding: UTF-8 -*- 2 print "Let‘s practice everything." 3 print ‘You\‘d need to know \‘bout escape with \\ that do \n newlines and \t tabs.‘ 4 5 poem = """ 6 \tThe lovely world 7 with logic so firmly planted 8 can not discern \n the needs of lovely 9 nor comprehend passion from intuition 10 and requires an explaniation 11 \n\t\t where there is none. 12 """ 13 14 print "--------------------" 15 print poem 16 print "--------------------" 17 18 five = 10 - 2 + 3 - 6 19 print "This should be five:%s" %five 20 21 def secret_formula (started):#函数后面永远不记得加":"!!!! 22 jelly_beans = started * 500#这里出现了一个IndentationError:unexpected indent,这是由于下面那几个命令行没有对齐(要求几个tab和几个空格完全相同。解决方法:视图-显示符号-显示空格与制表符 23 jars = jelly_beans / 1000 24 crates = jars / 100 25 return jelly_beans,jars,crates#创建函数后,返回三个变量值 26 27 start_point = 10000 28 beans,jars, crates = secret_formula(start_point)#这个有点类似argv的那个操作,把函数的最后三个变量给解压出来放到这三个新的变量里边。 29 #函数内部的变量都是临时的,当函数返回之后,返回值可以被赋予另一个变量。 30 print "With a starting point of:%d" % start_point 31 print "We‘d have %d beans, %d jars, and %d crates." %(beans, jars, crates) 32 33 start_point = start_point / 10 34 35 print "We can also do that this way:" 36 print "We‘d have %d beans, %d jars, and %d crates." % secret_formula(start_point)
标签:practice rom nbsp 显示 where and error: als erro
原文地址:http://www.cnblogs.com/dingtou00/p/7758176.html