首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

关于缩进,该怎么处理

2012-10-17 
关于缩进为何不能。。。例:numinput(Enter a number:)if num0:print the number is positiveelif num0

关于缩进
为何不能。。。

例:
num=input("Enter a number:")
if num>0:
print "the number is positive"
elif num<0:
print "the number is negative"
  print 300

而非要写成:

num=input("Enter a number:")
if num>0:
print "the number is positive"
elif num<0:
print "the number is negative"
  print 300

意思就是说print 300为何不能跟上一个print对齐呢,还要缩进一次为何?

上一个例子的写法错在什么地方?


[解决办法]

Python code
num=input("Enter a number:")if num>0:    print "the number is positive"elif num<0:    print "the number is negative"    print 300
[解决办法]
你的编辑器还是python解释器有问题吧,正常情况你贴出的那两个都会报缩进错误...

热点排行