python学习心得
时间:2010-11-07 来源:LinuxOSEDBA
这个东西做完半夜开始看的,当时很兴奋,觉得是个不错的东西,今天就继续看。现在敲了几行,看看如何好玩了。就这样学习,也是就这样慢慢的遇到问题,当然这就是学习了。遇到了几个貌似是很多初学者都遇到的问题吧,所以记录下来。。。
我就是希望看看if-else的运行效果,但是就这个就遇到了问题了 ,code如下: IDLE 2.6.2 >>>
>>> testdata = 12 >>> print testdata 12 >>> if testdata !=1: testdata = 12
>>> else: SyntaxError: invalid syntax >>> if testdata != 1: testdata = 51
>>> print testdata 51 >>> if testdata != 12: testdata = 21 else: File "<pyshell#13>", line 3 else: ^ IndentationError: unindent does not match any outer indentation level >>> if testdata != 12: testdata = 21
>>> testdata 21 >>> if testdata != 12: testdata = 12 else: test = 32
>>> testdata 12 >>> if testdata != 12: testdata = 32 else: testdata = 43
>>> testdatqa
Traceback (most recent call last): File "<pyshell#29>", line 1, in <module> testdatqa NameError: name 'testdatqa' is not defined >>> testdata 43 >>> 下面的才是真正的if-else 哈哈
我就是希望看看if-else的运行效果,但是就这个就遇到了问题了 ,code如下: IDLE 2.6.2 >>>
>>> testdata = 12 >>> print testdata 12 >>> if testdata !=1: testdata = 12
>>> else: SyntaxError: invalid syntax >>> if testdata != 1: testdata = 51
>>> print testdata 51 >>> if testdata != 12: testdata = 21 else: File "<pyshell#13>", line 3 else: ^ IndentationError: unindent does not match any outer indentation level >>> if testdata != 12: testdata = 21
>>> testdata 21 >>> if testdata != 12: testdata = 12 else: test = 32
>>> testdata 12 >>> if testdata != 12: testdata = 32 else: testdata = 43
>>> testdatqa
Traceback (most recent call last): File "<pyshell#29>", line 1, in <module> testdatqa NameError: name 'testdatqa' is not defined >>> testdata 43 >>> 下面的才是真正的if-else 哈哈
相关阅读 更多 +