New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于编码问题 #92

Closed
onsunsl opened this Issue Sep 11, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@onsunsl

onsunsl commented Sep 11, 2017

在代码总使用style = 0输出pinyin如下:

    textPY = pinyin(text, style=0)  # 全部拼音
    textSM = pinyin(text, style=3)  # 全部声母
    textYM = pinyin(text, style=5)  # 全部韵母
    logging.debug('{0}, {1}'.format(text, textPY))

win10 python3.5 输出两种不同结果。

pyinstaller 打包运行结果:
[line:389] - DEBUG: ['大', '家', '好'], [['dà'], ['jiā'], ['hǎo']]

源码运行结果:
[line:389] - DEBUG: ['大', '家', '好'], [['da'], ['jia'], ['hao']]

会不会是编码问题?

@onsunsl

This comment has been minimized.

onsunsl commented Sep 12, 2017

测试代码:

import pypinyin
text = '大家好'
print(text, pypinyin.pinyin(text, style = 0))

在pycharm里能正常输出:
Building prefix dict from the default dictionary ...
Loading model from cache C:\Users\onsun\AppData\Local\Temp\jieba.cache
Loading model cost 0.991 seconds.
大家好 [['da'], ['jia'], ['hao']]
Prefix dict has been built succesfully.

pyinstaller test.py
75 INFO: PyInstaller: 3.3.dev0+c45dabfeb
75 INFO: Python: 3.5.3
76 INFO: Platform: Windows-10-10.0.14393-SP0
77 INFO: wrote D:\AnyCode\robot3DWorkplace\server\project\testPyPinyin.spec
79 INFO: UPX is not available.
98 INFO: Extending PYTHONPATH with paths
.............

test.exe
Building prefix dict from the default dictionary ...
Loading model from cache C:\Users\onsun\AppData\Local\Temp\jieba.cache
Loading model cost 0.944 seconds.
Prefix dict has been built succesfully.
大家好 [['dà'], ['jiā'], ['hǎo']]

@mozillazg

This comment has been minimized.

Owner

mozillazg commented Sep 12, 2017

这个是因为用 pyinstaller 打包的问题。

@mozillazg

This comment has been minimized.

Owner

mozillazg commented Sep 12, 2017

@onsunsl 麻烦试一下 #93 的改动是否解决了你的问题。

@onsunsl

This comment has been minimized.

onsunsl commented Sep 13, 2017

好了。按#93的改动方法解决了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment