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
liuxurong
V2EX  ›  Python

Python 2.7.3 有什么办法输入 é

  •  
  •   liuxurong · 2012-08-12 23:51:18 +08:00 · 4268 次点击
    这是一个创建于 4267 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我用Windows 自带的IDLE

    输入

    >>> a = "é"
    Unsupported characters in input

    会出现这个错误。

    我已经保存文件为UTF-8,并在头部加上#-*-coding:utf-8-*-,#-*-encoding=utf-8 仍是不行。

    如果不能换Python3,

    怎么办?
    17 条回复    1970-01-01 08:00:00 +08:00
    lilydjwg
        1
    lilydjwg  
       2012-08-13 00:23:25 +08:00   ❤️ 2
    不要用 IDLE。
    liuxurong
        2
    liuxurong  
    OP
       2012-08-13 00:32:35 +08:00
    a="é"

    a="é"

    诡异。第二个可以,第一个就出现上面的错误。
    liuxurong
        3
    liuxurong  
    OP
       2012-08-13 00:32:47 +08:00
    fanzeyi
        4
    fanzeyi  
       2012-08-13 00:40:51 +08:00
    a = u"é"

    ?
    fanzeyi
        5
    fanzeyi  
       2012-08-13 00:41:31 +08:00   ❤️ 1
    a = 'e\xcc\x81'

    a = u'e\u0301'

    ...
    ljbha007
        6
    ljbha007  
       2012-08-13 00:57:29 +08:00   ❤️ 1
    字符串前加u
    liuxurong
        7
    liuxurong  
    OP
       2012-08-13 01:08:01 +08:00
    @fanzeyi
    a=u"é"
    Unsupported characters in input
    liuxurong
        8
    liuxurong  
    OP
       2012-08-13 01:08:39 +08:00
    @fanzeyi 乱码

    a = 'e\xcc\x81'
    >>> print a
    e虂
    fanzeyi
        9
    fanzeyi  
       2012-08-13 01:10:44 +08:00
    @liuxurong u'e\u0301' 呢?
    liuxurong
        10
    liuxurong  
    OP
       2012-08-13 01:20:16 +08:00
    @fanzeyi 这一个可以... 我有个文件名带有那个字符.. open不了..非用那个不可
    fanzeyi
        11
    fanzeyi  
       2012-08-13 01:21:34 +08:00   ❤️ 1
    @liuxurong 嘛…… Windows 这种奇怪的系统出现这样的问题不足为奇
    est
        12
    est  
       2012-08-13 09:17:40 +08:00
    用这个 u'\xe9'

    严格的说LZ的 é 是 e 加上一个 diacritical mark
    BOYPT
        13
    BOYPT  
       2012-08-13 12:43:10 +08:00   ❤️ 1
    Off topic 一下: “Windows 自带的IDLE” ...
    tywtyw2002
        14
    tywtyw2002  
       2012-08-13 14:25:58 +08:00
    a = u"é"
    clowwindy
        15
    clowwindy  
       2012-08-14 18:39:08 +08:00
    用 cygwin 里的 python console。
    lilydjwg
        16
    lilydjwg  
       2012-08-14 18:44:16 +08:00
    @liuxurong 第一个是组合字母(由两个码点组成)。总之呢,不要用 IDLE,难用死了。为了替换掉 Windows 上更难用的 cmd.exe,我特地写了个通过网络在 Linux 上进行行编辑的程序(见我博客或 github)。
    suckli
        17
    suckli  
       2012-08-14 20:24:25 +08:00
    可以使用gvim
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2810 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 11:43 · PVG 19:43 · LAX 04:43 · JFK 07:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.