将 raw_input 提示编码成多行...?

coding raw_input prompt into multiple lines...?

这里是新手。我在循环中得到了这个 raw_input 提示,所以它是缩进的;

userInput = raw_input('Enter n to deal a new hand, r to replay the last\
hand, or e to end game: ')

当我 运行 时,我在 "last" 和 "hand" 之间得到 2 个 space(缩进)标签。有没有办法消除这个差距?

非常感谢。

您可以使用 string literal concatenation:

userInput = raw_input(
    'Enter n to deal a new hand, r to replay the last '
    'hand, or e to end game: ')

Multiple adjacent string literals (delimited by whitespace), possibly using different quoting conventions, are allowed, and their meaning is the same as their concatenation. Thus, "hello" 'world' is equivalent to "helloworld". This feature can be used to reduce the number of backslashes needed, to split long strings conveniently across long lines, or even to add comments to parts of strings