推荐学习书目
› 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
crny520
V2EX  ›  Python

请教selenium的输入中文问题

  •  
  •   crny520 · Nov 28, 2012 · 5288 views
    This topic created in 5088 days ago, the information mentioned may be changed or developed.
    已经设置了sys.setdefaultencoding(UTF8)

    driver.find_element_by_id("firstname").send_keys("李")

    一直都出错。。。
    Supplement 1  ·  Dec 4, 2012
    已经解决....
    9 replies  •  1970-01-01 08:00:00 +08:00
    crny520
    crny520
    OP
    Nov 28, 2012
    1
    没有人帮忙?
    ergatea
    ergatea
    Nov 28, 2012
    2
    u"李"
    crny520
    crny520
    OP
    Nov 28, 2012
    3
    @ergatea 一样出错
    Brutal
    Brutal
    Nov 28, 2012
    4
    报什么错?

    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')

    这样呢?
    reus
    reus
    Nov 28, 2012
    5
    你怎么知道出错的?
    crny520
    crny520
    OP
    Nov 28, 2012
    6
    @reus 运行的时候有提示嘛....
    reus
    reus
    Nov 29, 2012
    7
    @crny520 所以提问时应该提供尽可能多的信息,说出错就应该把错误信息也列出来
    venglide
    venglide
    Nov 30, 2012
    8
    问题解决了没有,可以把出错信息贴出来给大家看看,关于python的编码问题,可以参看:http://lobstertech.com/python_unicode.html
    memorybox
    memorybox
    Nov 30, 2012
    9
    driver.find_element_by_id("firstname").send_keys(u"李")
    这样试试
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3006 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 10:57 · PVG 18:57 · LAX 02:57 · JFK 05:57
    ♥ Do have faith in what you're doing.