Python打印问题

时间:2015-07-11 08:57:10

标签: python

print "I will now count my slaves:"

print "females", 50 + 80 \ 10
print "males", 10 \ 2
print "Is it true that 6 > 7?"
print "What is 59 + 27?"

出于某种原因,它告诉我:

    print "females", 50 + 80 \ 10
                                ^
SyntaxError: unexpected character after line continuation character

1 个答案:

答案 0 :(得分:6)

\字符是行继续符,而不是除法运算符。它通常用于告诉Python将行连接在一起:

foo = "This is a long line that won't fit inside 80 characters " \
      "so the line continuation character is one way to extend " \
      "the logical line across multiple physical lines."

使用/进行分割:

print "females", 50 + 80 / 10
print "males", 10 / 2