V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2012-11-28 16:55:42 +08:00 · 4033 次点击
    这是一个创建于 4173 天前的主题,其中的信息可能已经有所发展或是发生改变。
    已经设置了sys.setdefaultencoding(UTF8)

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

    一直都出错。。。
    第 1 条附言  ·  2012-12-04 21:35:06 +08:00
    已经解决....
    9 条回复    1970-01-01 08:00:00 +08:00
    crny520
        1
    crny520  
    OP
       2012-11-28 17:10:51 +08:00
    没有人帮忙?
    ergatea
        2
    ergatea  
       2012-11-28 17:12:42 +08:00
    u"李"
    crny520
        3
    crny520  
    OP
       2012-11-28 18:02:52 +08:00
    @ergatea 一样出错
    Brutal
        4
    Brutal  
       2012-11-28 19:01:04 +08:00
    报什么错?

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

    这样呢?
    reus
        5
    reus  
       2012-11-28 21:32:22 +08:00
    你怎么知道出错的?
    crny520
        6
    crny520  
    OP
       2012-11-28 21:45:43 +08:00
    @reus 运行的时候有提示嘛....
    reus
        7
    reus  
       2012-11-29 03:23:15 +08:00
    @crny520 所以提问时应该提供尽可能多的信息,说出错就应该把错误信息也列出来
    venglide
        8
    venglide  
       2012-11-30 12:09:24 +08:00
    问题解决了没有,可以把出错信息贴出来给大家看看,关于python的编码问题,可以参看:http://lobstertech.com/python_unicode.html
    memorybox
        9
    memorybox  
       2012-11-30 19:11:36 +08:00
    driver.find_element_by_id("firstname").send_keys(u"李")
    这样试试
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2257 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:23 · PVG 17:23 · LAX 02:23 · JFK 05:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.