这是我的脚本:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import font_manager, rc
f_name = font_manager.FontProperties(fname='C:\Windows\Fonts\HYHWPEQ.ttf').get_name()
rc('font', family=f_name)
pulse = np.loadtxt('data/pulse.txt')
print(pulse)
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-1-2a4b229719d8> in <module>()
5 f_name = font_manager.FontProperties(fname='C:\Windows\Fonts\HYHWPEQ.ttf').get_name()
6 rc('font', family=f_name)
----> 7 pulse = np.loadtxt('data/pulse.txt')
8 print(pulse)
C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding)
1042 try:
1043 while not first_vals:
-> 1044 first_line = next(fh)
1045 first_vals = split_line(first_line)
1046 except StopIteration:
UnicodeDecodeError: 'cp949' codec can't decode byte 0xec in position 0: illegal multibyte sequence
我想使用韩文使用的文件,但是'cp949'编解码器无法解码字节0xec。我该如何解决这个问题?