Cea*_*ase 35 python comments commenting
有没有在python中结束单行注释的方法?
就像是
/*This is my comment*/ some more code here...
Run Code Online (Sandbox Code Playgroud)
The*_*nse 25
Python中的空格非常重要,除了#到达行尾的注释之外,还不允许任何其他类型的注释.拿这个代码:
x = 1
for i in range(10):
x = x + 1
/* Print. */ print x
Run Code Online (Sandbox Code Playgroud)
因为缩进确定了范围,所以解析器没有很好的方法来了解控制流.它无法合理地消除注释,然后执行代码.(这也使代码对人类的可读性降低.)因此没有内联注释.
小智 12
您可以插入内嵌注释。像这样
x=1; """ Comment """; x+=1; print(x);
Run Code Online (Sandbox Code Playgroud)
我的Python版本是“ 3.6.9 ”