biglih
V2EX  ›  问与答

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

  •  
  •   biglih · Jul 16, 2016 · 2905 views
    This topic created in 3761 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
    biglih
    OP
    Jul 16, 2016
    1
    好吧解决了 还是 python 的编码问题 fout = open('output.html', 'w', encoding='utf-8')
    jugelizi
    jugelizi
    Jul 16, 2016
    2
    ...亏你没有用 python2 3 的编码已经填了好多坑
    shyling
    shyling
    Jul 16, 2016
    3
    decode
    uuuing
    uuuing
    Jul 16, 2016
    4
    @jugelizi 2 还好吧~
    8023
    8023
    Jul 16, 2016
    5
    字符串 = 字符串.decode('utf-8')
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1570 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 23:07 · PVG 07:07 · LAX 15:07 · JFK 18:07
    ♥ Do have faith in what you're doing.