import random
print "I can sense your mood through your touches on keyboard"
print "you are .........."
mood=random.range(3)
if mood==0:
print \
"""
|---------------|
| |
| 0 0 |
| |
| < |
| - - |
| - - |
| - - - |
|---------------|
""":
elif mood==1:
print"your mood is"
print \ """
|==============| |
| 0 0 |
| |
| ---------- |
| |
|==============|
neutral """:
elif mood==2:
print" u r sad dear"
print \
"""
|===============|
| 0 0 |
| |
| - - - |
| - - |
| - - |
|===============|
"""
else:
print " u r really in a bad mood"
print " today..........."
raw_input ("\n\n\npress enter to exit")
不知道为什么它会显示语法错误
答案 0 :(得分:2)
不要用冒号结束打印声明。中性一词之后的一个冒号
neutral """:
(第17行还有另一个人)
你也不能
print \ """
因为\
是续行字符,所以在此之后你不应该有任何字符。
答案 1 :(得分:0)
试试这个
在打印
后删除:
使用randrange()
替换range()
import random
print "i can sence your mood through your touches on keyboard"
print "you are .........."
mood=random.randrange(3)
if mood==0:
print \
"""
|---------------|
| |
| 0 0 |
| |
| < |
| - - |
| - - |
| - - - |
|---------------|
"""
elif mood==1:
print"your mood is"
print \
"""
|==============| |
| 0 0 |
| |
| ---------- |
| |
|==============|
neutral """
elif mood==2:
print" u r sad dear"
print \
"""
|===============|
| 0 0 |
| |
| - - - |
| - - |
| - - |
|===============|
"""
else:
print " u r really in a bad mood"
print " today..........."
raw_input ("\n\n\npress enter to exit")