所以我正在处理win32com.client模块。我做了一些网络抓取工作,以制作所有大量枚举的数据框。 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是我用来生成文件的代码。
答案 0 :(得分:2)
使用open
编写文本文件而不指定encoding
时,将使用与系统有关的默认编码(可以使用locale.getpreferredencoding(False)
进行检索)。
Python代码文件应采用UTF-8编码,因此解决方案是在编写代码文件时在encoding="utf-8"
函数中显式指定open
。
答案 1 :(得分:1)
您的文字内容如下:
program readmixnum
implicit none
integer::i
complex::cdat(4,2)
do i=1, 4
read(100,*) cdat(i,1:2)
write(*,*) cdat(i,1:2)
end do
end program
我希望一旦您知道位置和内容,就可以解决此=)
ps。可疑部分是:>>> text[16700:16900]
"ith no border and callout line segments forming a U-shape', 183: 'Line inverse', 166: 'Division symbol \xc3\x83\xc2\xb7', 167: 'Equivalence symbol =', 164: 'Subtraction symbol -', 165: 'Multiplication symbol "