代码如下:
#!/usr/bin/env python # -*- coding: utf-8 -*- url = raw_input('Please enter the URl:') domain = url[11:-4] print("Domain name:" + domain)
运行报错:
SyntaxError: Non-ASCII character '\xef' in file C:/Users/PycharmProjects/untitled/ysf/ysf.
解决方法:
前面两个#号部分位置换一下,编码方式放在第一位置
# -*- coding: utf-8 -*- #!/usr/bin/env python url = raw_input('Please enter the URl:') domain = url[11:-4] print("Domain name:" + domain)