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

你为什么非要 -*-

  •  
  •   master13 · 2016-01-05 17:26:31 +08:00 · 3786 次点击
    这是一个创建于 3038 天前的主题,其中的信息可能已经有所发展或是发生改变。
    • 声明 python 源代码编码有很多种方法,明明#coding:utf8多简洁,你为什么非要用#-*- coding: utf-8 -*-,是因为它看起来更萌吗??!!!

    • 你看这里,人家都说了,只要 the first or second line must match the regular expression coding[:=]\s*([-\w.]+),匹配上这玩意就行。

    • 你喜欢萌,为什么不#-_- coding:utf8 -_-

    • #O(∩_∩)O coding:utf8 O(∩_∩)O 这个更萌!!

    19 条回复    2016-01-08 10:34:02 +08:00
    master13
        1
    master13  
    OP
       2016-01-05 17:27:49 +08:00
    #(๑¯ω¯๑) coding:utf8 (๑¯ω¯๑)
    lao454490095
        2
    lao454490095  
       2016-01-05 17:29:59 +08:00
    楼主好样的,以后试试 #O(∩_∩)O coding:utf8 O(∩_∩)O ,哈哈哈哈
    chmlai
        3
    chmlai  
       2016-01-05 17:32:12 +08:00
    编辑器自动补全的
    vanxining
        5
    vanxining  
       2016-01-05 17:38:17 +08:00 via Android
    我也不知道啊,大家都这用的。原来还有其他用法……
    florije
        6
    florije  
       2016-01-05 17:38:57 +08:00
    楼上是来源正解,不过 LZ 也说的对,毕竟一般的使用哪种写法就足够了。
    Tink
        7
    Tink  
       2016-01-05 17:39:01 +08:00
    我同三楼,编辑器自动的
    florije
        8
    florije  
       2016-01-05 17:39:23 +08:00
    @florije ……看一眼的功夫多了个 5 楼,只能说 4 楼正解了。
    9hills
        9
    9hills  
       2016-01-05 17:41:01 +08:00
    你喜欢萌,为什么不#-_- coding:utf8 -_-
    以后就用这个了
    Hello1995
        10
    Hello1995  
       2016-01-05 17:41:23 +08:00 via Android
    这是 emacs 字符集相关的历史遗留问题…
    GHfan
        11
    GHfan  
       2016-01-05 17:58:59 +08:00
    表示,在项目里一直推荐他们用 #coding:utf8
    我要用 #-_- coding:utf8 -_- 报复他们!!
    tobyxdd
        12
    tobyxdd  
       2016-01-05 19:01:01 +08:00 via Android
    #😃 coding: utf-8 😃
    mengzhuo
        13
    mengzhuo  
       2016-01-05 19:12:02 +08:00
    vim 自动补齐的……
    bertonzh
        14
    bertonzh  
       2016-01-05 19:42:52 +08:00
    #+_+ coding:utf8 +_+
    clino
        15
    clino  
       2016-01-05 19:48:49 +08:00
    #ლↀѡↀლcoding: utf-8ლↀѡↀლ
    zsj950618
        16
    zsj950618  
       2016-01-06 02:29:50 +08:00 via Android
    pep0263 里说了啊,为了方便各种各样的编辑器识别啊。。。。

    line in the file, such as:

    # coding=<encoding name>

    or (using formats recognized by popular editors)

    #!/usr/bin/python
    # -*- coding: <encoding name> -*-
    songkaiape
        17
    songkaiape  
       2016-01-06 10:41:15 +08:00
    @clino 看到这里忍不住笑了
    chenyuxiaodhr
        18
    chenyuxiaodhr  
       2016-01-06 12:13:15 +08:00
    #/ w\ coding:utf8 / w\
    rxkh
        19
    rxkh  
       2016-01-08 10:34:02 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1289 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:16 · PVG 01:16 · LAX 10:16 · JFK 13:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.