# Enter a code
age = int(input("请输入你的年龄"))
if age < 18:
print('teenager')
else:
print('adult')# Enter a code
# -*- coding: UTF-8 -*-
age = int(input("请输入你的年龄"))
if age < 18:
print('teenager')
else:
print('adult')之后会报另一个错误
运行失败
Traceback (most recent call last):
File "index.py", line 3, in
age = int(input("请输入你的年龄"))
EOFError: EOF when reading a line
请输入你的年龄EOFError: EOF when reading a line # 如果未向input()提供数据,则会发生EOF错误
编译错误提示你了,在第二行,就是你的编码没调用“中文”所以识别不出“请输入你的年龄”这几个字
File "index.py", line 2 SyntaxError: Non-ASCII character '\xe8' in file index.py on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details