所以我在用win32做一些工作com客户端模块。我做了一些网络垃圾来制作大量枚举的数据帧。webscrapping是成功的,但是一个模块将不会加载,除非我注释掉行。你知道吗
我对代码做了gist,因为其中有几行几乎是13k个字符长。你知道吗
我尝试import office_reverse_enumerations.py
时的错误是
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe2 in position 0: unexpected end of data
在17号线。如果我把第17行注释掉,就行了。你知道吗
我通过编程生成了那行,好吧,所有的行。你知道吗
一个例子是
enum_file.write(f"{enum_names[idx][df_idx]}_reverse = pd.DataFrame.from_dict({df_r_enum.to_dict()})\n")
>>> import office_reverse_enumerations
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Delengowski-Mobile\Documents\Gits\power_point_generator\office_reverse_enumerations.py", line 17
^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe2 in position 0: unexpected end of data
Here是我用来生成文件的代码。你知道吗
您的文本包含以下内容:
我希望一旦你知道了位置和内容,你就能解决这个问题()
另外,可疑部分是:
166: 'Division symbol \xc3\x83\xc2\xb7'
使用
open
写入文本文件而不指定encoding
时,将使用依赖于系统的默认编码(可以使用locale.getpreferredencoding(False)
检索)。你知道吗Python代码文件应该是UTF-8编码的,因此解决方案是在编写代码文件时在
open
函数中显式指定encoding="utf-8"
。你知道吗相关问题 更多 >
编程相关推荐