Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 执行时python中出现语法错误 随机导入 打印“我可以通过触摸键盘感受你的情绪” 打印“你是……” 情绪=随机。范围(3) 如果mood==0: 印刷品\ """ |---------------| | | | 0 0 | | | | < | | - - | | - - | | - - - | |---------------| """: elif mood==1: 打印“你的心情是” 打印\“ |==============| | | 0 0 | | | | ---------- | | | |==============| 中性“”: elif mood==2: 打印“你很伤心,亲爱的” 印刷品\ """ |===============| | 0 0 | | | | - - - | | - - | | - - | |===============| """ 其他: 打印“你真的心情不好” 打印“今天……” 原始输入(“\n\n\n按enter键退出”)_Python 2.7 - Fatal编程技术网

Python 2.7 执行时python中出现语法错误 随机导入 打印“我可以通过触摸键盘感受你的情绪” 打印“你是……” 情绪=随机。范围(3) 如果mood==0: 印刷品\ """ |---------------| | | | 0 0 | | | | < | | - - | | - - | | - - - | |---------------| """: elif mood==1: 打印“你的心情是” 打印\“ |==============| | | 0 0 | | | | ---------- | | | |==============| 中性“”: elif mood==2: 打印“你很伤心,亲爱的” 印刷品\ """ |===============| | 0 0 | | | | - - - | | - - | | - - | |===============| """ 其他: 打印“你真的心情不好” 打印“今天……” 原始输入(“\n\n\n按enter键退出”)

Python 2.7 执行时python中出现语法错误 随机导入 打印“我可以通过触摸键盘感受你的情绪” 打印“你是……” 情绪=随机。范围(3) 如果mood==0: 印刷品\ """ |---------------| | | | 0 0 | | | | < | | - - | | - - | | - - - | |---------------| """: elif mood==1: 打印“你的心情是” 打印\“ |==============| | | 0 0 | | | | ---------- | | | |==============| 中性“”: elif mood==2: 打印“你很伤心,亲爱的” 印刷品\ """ |===============| | 0 0 | | | | - - - | | - - | | - - | |===============| """ 其他: 打印“你真的心情不好” 打印“今天……” 原始输入(“\n\n\n按enter键退出”),python-2.7,Python 2.7,不知道为什么会显示语法错误不要用冒号结束print语句。在单词neutral后加一个冒号 neutral”“: (17号线上还有一个) 你也不能有 print\” 因为\是行连续字符,所以之后不应该有任何字符 试试这个 在打印后删除: 使用randrange()替换range() 随机导入 打印“我可以通过触摸键盘感受到你的情绪” 打印“你是……” 情绪=随机。随机范围(3) 如果mood==0: 印刷品\ """ |---------------| |

不知道为什么会显示语法错误

不要用冒号结束print语句。在单词neutral后加一个冒号

neutral”“:

(17号线上还有一个)

你也不能有

print\”

因为
\
是行连续字符,所以之后不应该有任何字符

试试这个

在打印后删除

使用
randrange()
替换
range()

随机导入
打印“我可以通过触摸键盘感受到你的情绪”
打印“你是……”
情绪=随机。随机范围(3)
如果mood==0:
印刷品\
""" 
|---------------|               
|               |
|  0       0    |
|               |
|     <         |
| -          -  |
|  -       -    |
|    - - -      |
|---------------|
"""
elif mood==1:
打印“你的心情是”
印刷品\
"""
|==============|              |
|   0     0    |
|              | 
|  ----------  |
|              |
|==============|
中性的
elif mood==2:
打印“你很伤心,亲爱的”
印刷品\
""" 
|===============|               
|   0     0     |
|               |
|    - - -      |
|  -       -    |
| -          -  | 
|===============|               
"""
其他:
打印“你真的心情不好”
打印“今天……”
原始输入(“\n\n\n按enter键退出”)

如果您查看控制台,它实际上会告诉您错误发生的确切位置您介意解释您所做的更改以及原因吗?删除:打印后使用无范围()随机方法,然后我替换使用randrange()替换范围()为什么替换rand?hi friends random不是提供范围()方法&i在print syntextif中删除“:”如果看到then的所有方法,则进入终端并键入python&import random,然后在dir之后输入(random)
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")
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")