Skip to main content
 首页 » 编程设计

python之Python 参数中的空格

2025年05月04日19mfrbuaa

几天前才开始学习 Python。

当我键入参数时,例如 print "Hello, World",我是否应该(或不应该)在 print 和字符串?或者,如果我想要变量 name = raw_input ("name?"),我应该在 name、=、 之间添加一个 spave raw_input 等?没有它似乎工作正常,但我不想开始养成将来会咬我的坏习惯。

请您参考如下方法:

Python 确实有自己的风格指南 (PEP 8),绝对值得您花时间阅读它。至于你说的:

    More than one space around an assignment (or other) operator to align it with another. 
 
    x = 1 
    y = 2 
    long_variable = 3 

更多信息:http://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements