V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · 4817 views
    This topic created in 4909 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
        1
    crny520  
    OP
       Nov 28, 2012
    没有人帮忙?
    ergatea
        2
    ergatea  
       Nov 28, 2012
    u"李"
    crny520
        3
    crny520  
    OP
       Nov 28, 2012
    @ergatea 一样出错
    Brutal
        4
    Brutal  
       Nov 28, 2012
    报什么错?

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

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