[英]SyntaxError: Non-UTF-8 code starting with '\xfe'
這是我的代碼,看起來不錯。
import ael
while True:
cmd = input('AEL > ')
result, error = ael.run(cmd)
if error: print(error.as_string())
else: print(result)
但是每當我運行它時,無論它是來自 PyCharm(我的 IDE)還是來自終端,我總是會收到以下錯誤: SyntaxError: Non-UTF-8 code starting with '\xfe' in file C:\Users\[...] on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
SyntaxError: Non-UTF-8 code starting with '\xfe' in file C:\Users\[...] on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
這是我嘗試解決此問題的方法:
# coding=utf-8
# -*- coding: utf-8 -*-
我將如何解決這個問題? 任何潛在的解決方案?
您的問題似乎是字節順序標記( https://en.wikipedia.org/wiki/Byte_order_mark )的混合,並且文件以不同的字符集編碼。
字符集可能是一團糟,只有一個解決方案:始終保持所有 UTF-8 格式,並且它應該在大多數情況下都能正常工作。 如果文件不是 UTF-8,則使用 Notepad++ 之類的工具將其轉換為 UTF-8。 通常這可以解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.