#39265: 第二筆測資疑似編碼非UTF-8,導致 Python 無法正確輸入測資


kaeteyaruyo@gmail.com (kinoe_T)

學校 : 國立成功大學
編號 : 81196
來源 : [140.113.136.221]
最後登入時間 :
2024-01-31 16:39:28
e524. 106 彰雲嘉區複賽 - Q4 變位字判斷 -- 106彰雲嘉資訊學科能力複賽 | From: [140.113.136.221] | 發表日期 : 2024-01-30 00:33

如題,第二題輸入時會回報以下錯誤:

您的程式被監控系統中斷,可能是程式無法正常結束所導致。
Traceback (most recent call last):
  File "/13221113_e524/code_13221113.py", line 2, in 
    N = int(input())
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position ...

此問題應來源於輸入文字檔的編碼錯誤。不知道是否能請題目上傳者修正?謝謝!

 
#39266: Re: 第二筆測資疑似編碼非UTF-8,導致 Python 無法正確輸入測資


asnewchien@gmail.com (david)

學校 : 不指定學校
編號 : 68108
來源 : [114.42.154.168]
最後登入時間 :
2024-04-27 22:14:03
e524. 106 彰雲嘉區複賽 - Q4 變位字判斷 -- 106彰雲嘉資訊學科能力複賽 | From: [1.168.11.89] | 發表日期 : 2024-01-30 12:08

如題,第二題輸入時會回報以下錯誤:

您的程式被監控系統中斷,可能是程式無法正常結束所導致。
Traceback (most recent call last):
  File "/13221113_e524/code_13221113.py", line 2, in 
    N = int(input())
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x81 in position ...

此問題應來源於輸入文字檔的編碼錯誤。不知道是否能請題目上傳者修正?謝謝!

import sys
import codecs
sys.stdin = codecs.getreader('latin-1')(sys.stdin.detach())



 
ZeroJudge Forum