PYTHON的超级小白问题。。raw_input语句提示错误,在线等
#!/usr/bin/python#Filename:if.pynumber=23guess=int(raw_input('Enteraninteger:'))ifgue...
#!/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--------------------
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
Traceback (most recent call last):
望解答,在线等 展开
# 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--------------------
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
Traceback (most recent call last):
望解答,在线等 展开
1个回答
2009-09-18
展开全部
int()里面不能是内部方法,可以这样
guess = raw_input('Enter an integer : ')
然后再用int(guess)
guess = raw_input('Enter an integer : ')
然后再用int(guess)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询