小白刚学python,raw_input语句出现错误。在线等解答!
今天刚接触的PYTHON..刚才看书的时候按着书上的写了一个,结果运行的时候出现错误。。。。。。。。。。。我用的是SCRIP.NET,开发包是在蓝蚂蚁上下的。#!/usr...
今天刚接触的PYTHON..刚才看书的时候按着书上的写了一个,结果运行的时候出现错误。。。。。。。。。。。我用的是SCRIP.NET,开发包是在蓝蚂蚁上下的。
#!/usr/bin/python
# Filename: if.py
number = 23
guess = int(raw_input('Enter an integer : '))
if guess == number:
print 'Congratulations, you guessed it.' # New block starts here
print "(but you do not win any prizes!)" # New block ends here
elif guess < number:
print 'No, it is a little higher than that' # Another block
# You can do whatever you want in a block ...
else:
print 'No, it is a little lower than that'
# you must have guess > number to reach here
print 'Done'
# This last statement is always executed, after the if statement is executed
结果运行的时候提示错误:
--------------------OwmEdit : Debug org.interp.python Script--------------------
Save File: F:\bccccccccccccc!\if.py
Create org.interp.python Interpret: Interp_Script
Start eval script F:\bccccccccccccc!\if.py at run mode...
Enter an integer :
Script eval error at line[6]
Result is: Traceback (most recent call last):
File "F:/bccccccccccccc!/if.py", line 6, in <module>
guess = int (raw_input)
TypeError: int() argument must be a string or a number, not 'builtin_function_or_method'
Traceback (most recent call last):
File "F:/bccccccccccccc!/if.py", line 5, in <module>
guess = int(raw_input('Enter an integer : '))
EOFError: EOF when reading a line
望解答,在线等 展开
#!/usr/bin/python
# Filename: if.py
number = 23
guess = int(raw_input('Enter an integer : '))
if guess == number:
print 'Congratulations, you guessed it.' # New block starts here
print "(but you do not win any prizes!)" # New block ends here
elif guess < number:
print 'No, it is a little higher than that' # Another block
# You can do whatever you want in a block ...
else:
print 'No, it is a little lower than that'
# you must have guess > number to reach here
print 'Done'
# This last statement is always executed, after the if statement is executed
结果运行的时候提示错误:
--------------------OwmEdit : Debug org.interp.python Script--------------------
Save File: F:\bccccccccccccc!\if.py
Create org.interp.python Interpret: Interp_Script
Start eval script F:\bccccccccccccc!\if.py at run mode...
Enter an integer :
Script eval error at line[6]
Result is: Traceback (most recent call last):
File "F:/bccccccccccccc!/if.py", line 6, in <module>
guess = int (raw_input)
TypeError: int() argument must be a string or a number, not 'builtin_function_or_method'
Traceback (most recent call last):
File "F:/bccccccccccccc!/if.py", line 5, in <module>
guess = int(raw_input('Enter an integer : '))
EOFError: EOF when reading a line
望解答,在线等 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询