相关疑难解决方法(0)

为什么python使用非常规的三引号来评论?

为什么python不使用C/C++/Java使用的传统风格的注释:

/**
 * Comment lines 
 * More comment lines
 */

// line comments
// line comments
//
Run Code Online (Sandbox Code Playgroud)

是否有特定原因或者它是否随意?

python comments coding-style

30
推荐指数
4
解决办法
5万
查看次数

Python评论:#与字符串

关于在Python源代码中放置注释的"标准"方法:

def func():
    "Func doc"
    ... <code>
    'TODO: fix this'
    #badFunc()
    ... <more code>

def func():
    "Func doc"
    ... <code>
    #TODO: fix this
    #badFunc()
    ... <more code>
Run Code Online (Sandbox Code Playgroud)

我更喜欢将一般注释写为字符串而不是前缀#的.官方的Python风格指南没有提到使用字符串作为注释(如果我在阅读时没有错过它).

我喜欢这种方式主要是因为我认为这个#角色看起来很丑陋.据我所知,这些字符串不做任何事情.

这样做有缺点吗?

python

24
推荐指数
3
解决办法
7426
查看次数

标签 统计

python ×2

coding-style ×1

comments ×1