python - Python编码风格中的空格

标签 python coding-style formatting

Python 教程说“在运算符周围和逗号后使用空格,但不要直接在括号结构内:a = f(1, 2) + g(3, 4)。” “不直接在括号结构内”到底是什么意思?

最佳答案

这可能来自 PEP 8 -- Style Guide for Python Code .具体请参阅“表达式和语句中的空格”部分。

从那个部分:

Avoid extraneous whitespace in the following situations:

- Immediately inside parentheses, brackets or braces.

  Yes: spam(ham[1], {eggs: 2})
  No:  spam( ham[ 1 ], { eggs: 2 } )

关于python - Python编码风格中的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9714161/

相关文章:

python - 替换python字符串中的特殊字母

python - 从组合框中选择数据位

c# - 如何在没有接口(interface)的情况下模拟多重继承?

html - Pandas HTML 输出条件格式 - 如果值在范围内则突出显示单元格

c# - C# 有自动代码格式化程序吗?

Python 脚本不会从 Aws Ubuntu 终端运行

.net - 学习应用程序编程的最佳资源? (.Net/ cocoa /等)

Java - 何时使用 'this' 关键字

javascript - 舍入 javascript 字符串并显示不带小数的美元格式

python - 在python中将0/1矩阵转换为二维网格图