|
发表于 2021-7-23 14:38:37
|
显示全部楼层
python3.8.9调试成功!
2 N6 t' G9 I" P. l6 Q; W! |' u5 j' Z+ `# w4 f9 U& }, f
做了如下修改:
8 {. S2 W/ L1 O0 a% P3 G( c' [# p0 d/ H* r
1.genMDX_ox4.py
. `9 R' T |. d8 i7 Q( B/ ~# K4 c) ?& @3 L& o/ i3 s3 y' t
(1)注释掉前三行# -*- coding: GBK -*- # coding: utf-8 # encoding=utf8,解决SyntaxError: encoding problem: GBK
) ]- O$ ~1 R3 S4 C3 q: V; Z$ J# b6 b, b# R- {$ f) D
(2)注释掉import sys reload(sys) sys.setdefaultencoding('utf-8'),python3不需要了& Q5 ?3 n- F, |( A: a# `6 e# ?
+ J- ~. j* h b# p/ \(3)打开、写入的文件加上当前路径(import os;current_path = os.path.dirname(__file__);current_path+"/OALD4_azure.txt",),解决No such file or directory:' R1 D, O- e- f$ W5 X, C% f# b" f/ l
1 H) w7 o. c9 F4 @(4)大神提示OALD4_azure.txt、about_OX4.txt使用utf-8格式。我试了下,两个文件转换为gb2312,代码修改为encoding='ANSI',也可以成功。另外,goldendict可以打开这两种编码的mdx,mdictpc版只能打开ANSI编码的mdx文件。1 Z! S8 G; ?! o/ v
9 d. _) x& O# p! W3 \
2.writemdict.py4 [' g3 Z+ I* D! `! ~
3 B: U" n& x6 _/ h# G9 m/ B修改 from cgi import escape为 from html import escape,解决cannot import name 'escape' from 'cgi' ,因为python3 cgi.py里面已经没有escape了。换成html,可以用,暂未发现问题。 |
评分
-
1
查看全部评分
-
|