2015-07-11 75 views
1
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?" 

出于某种原因,它让我看到:Python的打印问题

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

回答

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