Python编程风格

来源:互联网 发布:js打开新窗口post 编辑:程序博客网 时间:2024/05/16 13:53

We’ll have more to say about style as our programs become more complex, but a few pointers will be helpful already:

  1. use 4 spaces for indentation 缩进4个空格
  2. imports should go at the top of the file 应该在文件顶部导入
  3. separate function definitions with two blank lines 单独的函数定义直接有2行空格
  4. keep function definitions together 函数定义应该放在一起
  5. keep top level statements, including function calls, together at the bottom of the program 高级语句包括函数调用,应该一起放在程序的底部
0 0
原创粉丝点击