biglih
V2EX  ›  问与答

写了一个爬虫 无奈爬出的东西是这样的 目测编码问题

  •  
  •   biglih · Jul 16, 2016 · 2741 views
    This topic created in 3613 days ago, the information mentioned may be changed or developed.
    http://baike.baidu.com/view/21087.htm b'Python' b'\nPython\xef\xbc\x88\xe8\x8b\xb1\xe5\x9b\xbd\xe5\x8f\x91\xe9\x9f\xb3\xef\xbc\x9a/\xcb\x88pa\xc9\xaa\xce\xb8\xc9\x99n/ \xe7\xbe\x8e\xe5\x9b\xbd\xe5\x8f\x91\xe9\x9f\xb3\xef\xbc\x9a/\xcb\x88pa\xc9\xaa\xce\xb8\xc9\x91\xcb\x90n/\xef\xbc\x89,

    已经在 py 文件开头加入#coding utf-8

    初学 python 希望知道怎么解决编码问题

    Python 版本 3.5.2 IDE ECLIPSE+PyDev
    5 replies    2016-07-16 22:08:08 +08:00
    biglih
        1
    biglih  
    OP
       Jul 16, 2016
    好吧解决了 还是 python 的编码问题 fout = open('output.html', 'w', encoding='utf-8')
    jugelizi
        2
    jugelizi  
       Jul 16, 2016
    ...亏你没有用 python2 3 的编码已经填了好多坑
    shyling
        3
    shyling  
       Jul 16, 2016
    decode
    uuuing
        4
    uuuing  
       Jul 16, 2016
    @jugelizi 2 还好吧~
    8023
        5
    8023  
       Jul 16, 2016
    字符串 = 字符串.decode('utf-8')
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1621 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 16:15 · PVG 00:15 · LAX 09:15 · JFK 12:15
    ♥ Do have faith in what you're doing.