当我运行此代码时:
category
我收到了错误:
SyntaxError :文件中的非ASCII字符'\ xe2',未声明编码
答案 0 :(得分:1)
看起来您需要在脚本顶部设置编码以防止出现此错误。
<强>实施例强>
# -*- coding: utf-8 -*-
答案 1 :(得分:0)
As Rakesh pointed out, you can set an encoding cookie at the top of your script so that it handles non-ascii characters.
Alternatively, you could replace the double quotation marks around Ayodhya with ascii quotation marks:
str1= "Ram's birthplace is \"Ayodhya\" in Uttar Pradesh"