推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
a2z
V2EX  ›  Python

shift_jis 如何完美转换成 utf8?

  •  
  •   a2z · Feb 18, 2015 · 9042 views
    This topic created in 4112 days ago, the information mentioned may be changed or developed.
    用了codec.encode和codec.decode


    title='無料出会いサイト調査ファイル[地域別・セックス・逆援助・SMなどの攻略情報]'
    title=codecs.decode(title,charset,'replace')
    title=codecs.encode(title,"utf8","replace")

    無料出会いサイト調査ファイル[地域別・セックス・逆援助・SMなどの攻略情報]

    至少终端里看起来片假名全变成方块……
    16 replies    2016-06-22 20:02:16 +08:00
    ehs2013
        1
    ehs2013  
       Feb 18, 2015
    终端的字体很有可能不带半角片假名字体。
    建议输出到文本进入专业文本编辑器中查看。
    rikeinei
        2
    rikeinei  
       Feb 18, 2015
    if getEncoding(resultSF) == "shift-jis":
    resultSF = resultSF.decode('shift-jis').encode('utf-8')
    if getEncoding(resultSF) == "euc-jp":
    resultSF = resultSF.decode('euc-jp').encode('utf-8')
    loading
        3
    loading  
       Feb 18, 2015 via Android
    @ehs2013 指了一条明路,楼主,冲吧。
    rikeinei
        4
    rikeinei  
       Feb 18, 2015
    @a2z 楼主做啥工作的? 这个title的内容有点......
    a2z
        5
    a2z  
    OP
       Feb 18, 2015
    @rikeinei
    爬虫相关……这个title是碰巧……
    rikeinei
        6
    rikeinei  
       Feb 18, 2015
    @a2z 楼主,快说,报警了!风俗相关产业的从业人员?还是???
    a2z
        7
    a2z  
    OP
       Feb 18, 2015
    @rikeinei
    搜索引擎相关,有些日语的title显示出来编码不对……我随便挑了一个看着眼熟的(逃
    rikeinei
        8
    rikeinei  
       Feb 18, 2015
    @a2z 嘿嘿,想像一下啊,边看某网站,边写代码,结果随手拷贝一段文字用来做测试,恰好是。。。
    哈哈哈
    a2z
        9
    a2z  
    OP
       Feb 18, 2015
    @rikeinei
    人坚不拆……
    la0wei
        10
    la0wei  
       Feb 18, 2015 via Android
    @rikeinei 我觉着楼主是做国外H站的,我记得有个站可以根据番号看封面......暴露了
    jwk345
        11
    jwk345  
       Feb 18, 2015
    大年三十的还在折腾
    imn1
        12
    imn1  
       Feb 18, 2015
    终端只是字体问题,你终端使用的字体不支持半角片假字符
    rikeinei
        13
    rikeinei  
       Feb 18, 2015
    @la0wei 看标题应该不是你说的那个网站,你要想看,sod,dmm随便看了
    orancho
        14
    orancho  
       Feb 18, 2015
    楼主爬的是什么网站, sm圆月抛都出来了
    wdlth
        15
    wdlth  
       Feb 19, 2015
    逆援助……这不是找牛郎么……
    xiaotaoqi
        16
    xiaotaoqi  
       Jun 22, 2016
    数据处理,加我 QQ574632347 ,一起交流一下。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   873 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 51ms · UTC 22:05 · PVG 06:05 · LAX 15:05 · JFK 18:05
    ♥ Do have faith in what you're doing.