例1:
num=input('enter a number:')
if num>0:
print('positive')
elif num<0:
print('negative')
else:
print('zero')
enter a number:42
Traceback (most recent call last):
File "C:/Users/HP/AppData/Local/Programs/Python/Python36/yeah's program/判断数字.py", line 2, in <module>
if num>0:
TypeError: '>' not supported between instances of 'str' and 'int'
例2:
x=input('x:')
x:34
y=input('y:')
y:22
print xy
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(xy)?
print(xy)
Traceback (most recent call last):
File "<pyshell#57>", line 1, in <module>
print(xy)
TypeError: can't multiply sequence by non-int of type 'str'