Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.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程序在Windows7中运行良好,并打印到控制台,但在LinuxMint中出现错误?_Python_Linux_Windows - Fatal编程技术网

我的python程序在Windows7中运行良好,并打印到控制台,但在LinuxMint中出现错误?

我的python程序在Windows7中运行良好,并打印到控制台,但在LinuxMint中出现错误?,python,linux,windows,Python,Linux,Windows,我正在windows中编写一个程序。我启动了我的LinuxMintHardrive,出于某种原因,它在mint中给出了一个错误,而不是Windows7?以下是该程序的3个文件: main.py: #------------------------------------------------------------------------------- # Name: main.py # Purpose: An RPG (Roll playing game) where

我正在windows中编写一个程序。我启动了我的LinuxMintHardrive,出于某种原因,它在mint中给出了一个错误,而不是Windows7?以下是该程序的3个文件:

main.py:

#-------------------------------------------------------------------------------
# Name:        main.py
# Purpose:     An RPG (Roll playing game) where you wake up in a room and have
#              to figure out text based puzzles to escape.
#              The whole game will be done in a terminal (Shell) and will be
#              completely text and ascii code. This will be the main file.
#
# Author:      William Bryant
#
# Created:     15/12/2013
# Copyright:   (c) William Bryant 2013
#-------------------------------------------------------------------------------

import time
import ascii
import quests

#The function that starts/restarts the game
def init():
    """
    Calls all the functions to start the game/ restart the game
    """
    #Display a cool banner
    ascii.ywu_banner(2)

    START_INPUT = input("Press ENTER/RETURN on your keyboard to start the game")
    time.sleep(0.7)
    ascii.clear()

    #Game text.
    game_text()

def options():
    pass
#The text which is the main story line after the banner which gives the player
#A sense of what the setting is about
def game_text():
    """
    Prints out a bit of text 2 lines down and clears the screen every 4 or so
    seconds.
    """
    time.sleep(5)

    print("\n\nYour eyes gentally and gradually, open")
    time.sleep(4)
    ascii.clear()
    time.sleep(2)

    print("\n\nYou slowly gather your senses and sit up...")
    time.sleep(4.5)
    ascii.clear()
    time.sleep(2)

    print("\n\nYou look around the room, and try to make sense of the")
    print("environment you are in and to your surprise, you realise your in some")
    print("sort of a prison cell!")
    time.sleep(12.5)
    ascii.clear()
    time.sleep(2)

    print("\n\nYou place your hand on the wall...")
    time.sleep(3)
    ascii.clear()
    time.sleep(2)

    print("\n\n... It feels like some sort of metal.")
    time.sleep(4)
    ascii.clear()
    time.sleep(2)

    print('\n\n"How did I get here?", \nYou think to yourself')
    time.sleep(4)
    ascii.clear()
    time.sleep(2)

    quests.way_out_quest()
    time.sleep(2)
    print("\nYou accepted the quest" + ascii.WOODEN_DOOR)
    time.sleep(10)
    ascii.clear()

    ascii.clear()
    time.sleep(2)

    print("\nYou see a wooden door next to your bed with 5 buttons and a handel...  " + ascii.WOODEN_DOOR)
    time.sleep(10)
    ascii.clear()
    time.sleep(2)

    print("\n\nYou the figure out that it's some sort of combination lock.")
    time.sleep(4)
    ascii.clear()
    time.sleep(2)

    print("\n\nMmm, let me try this: ")
    time.sleep(4)
    ascii.clear()
    time.sleep(2)

#if the file is the main file then start the program
if __name__ == '__main__':
    init()
quest.py:

#-------------------------------------------------------------------------------
# Name:        quests
# Purpose:     To contain quests functions for the game "Yoy wake up..."
#
# Author:      William Bryant
#
# Created:     17/12/2013
# Copyright:   (c) William Bryant 2013
#-------------------------------------------------------------------------------

import time
import ascii
import main

#Error message if user executes the wrong file.
if __name__ == '__main__':
    print("[ERROR]: Do not run this file. Run main.py - this file should not be executed!")
    time.sleep(4)
    exit()

#Function for the first quest: do you want to find a way out?
def way_out_quest():
    """
    If the question is not answered, then the player can't move on. If they say
    yes, then they continue through the script. If they say no, then the init
    function is called from main.py
    """
    way_out_answered = False
    while way_out_answered == False:
        WAY_OUT_INPUT = input("Quest: Do you want to find a way out? ")
        if WAY_OUT_INPUT in ["yes", "Yes", "YES"]:
            way_out_answered = True


        elif WAY_OUT_INPUT in ["no", "No", "NO"]:
            way_out_answered = True
            time.sleep(2)
            ascii.clear()
            print("GAME\nOVER!")
            time.sleep (5)
            ascii.clear()
            main.init()

        else:
            print("Type yes or no. ")

        time.sleep(4)
ascii.py:

#-------------------------------------------------------------------------------
# Name:        ascii
# Purpose:     To create all the ascii art and graphic tools for the game:
#              "you wake up..."
#
# Author:      William Bryant
#
# Created:     15/12/2013
# Copyright:   (c) William 2013
#-------------------------------------------------------------------------------

import time
import os

WOODEN_DOOR = """ ______________________________
/_____/_____/_____/_____/_____/
 ._.                    ._.
 | |                    | |
 |_|   ______   ______  |_|
 |-|  /__1__/  /__2__/  |-|         ___________
 | |                    | |         || ||| ||||
 |_|                    |_|         || ||| ||||
 ._.                    ._.         ||_||| ||||
 | |                    | |        _||_|||_||||_
 |_|   ______           |_|
 |-|  /__3__/           |-|
 | |              /\    | |
 |_|              \/    |_|
 ._.                    ._.                                     _____
 | |                    | |        ____________________________|_____|
 |_|   ______   ______  |_|       | |______________________________| |
 |-|  /__4__/  /__5__/  |-|       | |                              | |
 | |                    | |       |_|                              |_|
 |_|                    |_|
  _____________________________________________________________________
 /_____/  /_____/__/_____/  /_____/  /_____/  /_____/  /_____/  /_____/
 /_____/  /_____/  /_____/  /_____/  /_____/  /_____/  /_____/  /_____/"""

#Error message if user executes the wrong file.
if __name__ == '__main__':
    print("[ERROR]: Do not run this file. Run main.py - this file should not be executed!")
    time.sleep(4)
    exit()

#Clear function
def clear():
    """
    Clears the console screen using the built in commands on a operating
    system (here linux and windows)
    """
    os.system(['clear','cls', "^L"][os.name == 'nt'])

#"Wake up..." title/banner at the start
def ywu_banner(num_of_times):
    """
    Prints You wake up...(the game name) in ascii code big letters into a
    console and clears the screen using the clear function above and reprints
    the message to make the dots at the end appear to be moving.
    """
    print("__     __                         _")
    time.sleep(0.25)
    print("\ \   / /                        | |")
    time.sleep(0.25)
    print(" \ \_/ /__  _   _  __      ____ _| | _____   _   _ _ __")
    time.sleep(0.25)
    print("  \   / _ \| | | | \ \ /\ / / _` | |/ / _ \ | | | | '_ \ ")
    time.sleep(0.25)
    print("   | | (_) | |_| |  \ V  V / (_| |   <  __/ | |_| | |_) | _ _ ")
    time.sleep(0.25)
    print("   |_|\___/ \__,_|   \_/\_/ \__,_|_|\_\___|  \__,_| .__(_|_|_)")
    time.sleep(0.25)
    print("                                                  | |    ")
    time.sleep(0.25)
    print("                                                  |_| ")
    time.sleep(0.25)
    clear()

    for foo in range(num_of_times):
        print("__     __                         _")
        print("\ \   / /                        | |")
        print(" \ \_/ /__  _   _  __      ____ _| | _____   _   _ _ __")
        print("  \   / _ \| | | | \ \ /\ / / _` | |/ / _ \ | | | | '_ \ ")
        print("   | | (_) | |_| |  \ V  V / (_| |   <  __/ | |_| | |_) | _  ")
        print("   |_|\___/ \__,_|   \_/\_/ \__,_|_|\_\___|  \__,_| .__(_|_)")
        print("                                                  | |    ")
        print("                                                  |_| ")
        time.sleep(0.7)
        clear()

        print("__     __                         _")
        print("\ \   / /                        | |")
        print(" \ \_/ /__  _   _  __      ____ _| | _____   _   _ _ __")
        print("  \   / _ \| | | | \ \ /\ / / _` | |/ / _ \ | | | | '_ \ ")
        print("   | | (_) | |_| |  \ V  V / (_| |   <  __/ | |_| | |_) |  ")
        print("   |_|\___/ \__,_|   \_/\_/ \__,_|_|\_\___|  \__,_| .__(_)")
        print("                                                  | |    ")
        print("                                                  |_| ")
        time.sleep(0.7)
        clear()

        print("__     __                         _")
        print("\ \   / /                        | |")
        print(" \ \_/ /__  _   _  __      ____ _| | _____   _   _ _ __")
        print("  \   / _ \| | | | \ \ /\ / / _` | |/ / _ \ | | | | '_ \ ")
        print("   | | (_) | |_| |  \ V  V / (_| |   <  __/ | |_| | |_) |  ")
        print("   |_|\___/ \__,_|   \_/\_/ \__,_|_|\_\___|  \__,_| .___/")
        print("                                                  | |    ")
        print("                                                  |_| ")
        time.sleep(0.7)
        clear()

        print("__     __                         _")
        print("\ \   / /                        | |")
        print(" \ \_/ /__  _   _  __      ____ _| | _____   _   _ _ __")
        print("  \   / _ \| | | | \ \ /\ / / _` | |/ / _ \ | | | | '_ \ ")
        print("   | | (_) | |_| |  \ V  V / (_| |   <  __/ | |_| | |_) | _ _ ")
        print("   |_|\___/ \__,_|   \_/\_/ \__,_|_|\_\___|  \__,_| .__(_|_|_)")
        print("                                                  | |    ")
        print("                                                  |_| ")
        time.sleep(0.7)
        clear()
#-------------------------------------------------------------------------------
#名称:ascii
#目的:为游戏创建所有ascii艺术和图形工具:
#“你醒了……”
#
#作者:威廉·布莱恩特
#
#创建日期:15/12/2013
#版权所有:(c)William 2013
#-------------------------------------------------------------------------------
导入时间
导入操作系统
木门“”______________________________
/_____/_____/_____/_____/_____/
._.                    ._.
| |                    | |
|_|   ______   ______  |_|
|-|  /__1__/  /__2__/  |-|         ___________
| |                    | |         || ||| ||||
|_|                    |_|         || ||| ||||
._.                    ._.         ||_||| ||||
| |                    | |        _||_|||_||||_
|_|   ______           |_|
|-|  /__3__/           |-|
| |              /\    | |
|_|              \/    |_|
._.                    ._.                                     _____
| |                    | |        ____________________________|_____|
|_|   ______   ______  |_|       | |______________________________| |
|-|  /__4__/  /__5__/  |-|       | |                              | |
| |                    | |       |_|                              |_|
|_|                    |_|
_____________________________________________________________________
/_____/  /_____/__/_____/  /_____/  /_____/  /_____/  /_____/  /_____/
/_____/  /_____/  /_____/  /_____/  /_____/  /_____/  /_____/  /_____/"""
#如果用户执行错误的文件,则显示错误消息。
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
打印(“[错误]:不运行此文件。运行main.py-不应执行此文件!”)
时间。睡眠(4)
退出()
#清晰功能
def clear():
"""
使用操作系统上的内置命令清除控制台屏幕
系统(此处为linux和windows)
"""
os.system(['clear'、'cls'、“^L”][os.name=='nt'])
#“唤醒…”开头的标题/横幅
def ywu_旗帜(次数):
"""
打印你醒来…(游戏名称)在ascii码大字母成一个
控制台并使用上面的清除功能清除屏幕,然后重新打印
使末尾的点看起来移动的消息。
"""
打印(“打印”)
睡眠时间(0.25)
打印(“\\/| |”)
睡眠时间(0.25)
打印(“\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
睡眠时间(0.25)
打印(\/\\\\\\/\/\/\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
睡眠时间(0.25)
打印(“| | | | | | | | | | | | | | | | | | | | | | | |
睡眠时间(0.25)
打印(“| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 124
睡眠时间(0.25)
打印(“| |”)
睡眠时间(0.25)
打印(“| |”)
睡眠时间(0.25)
清除()
对于范围内的foo(次数):
打印(“打印”)
打印(“\\/| |”)
打印(“\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(\/\\\\\\/\/\/\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(“| |(| | | | | | | | | | | | | | | | | | | | | |
打印(“| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
打印(“| |”)
打印(“| |”)
睡眠时间(0.7)
清除()
打印(“打印”)
打印(“\\/| |”)
打印(“\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(\/\\\\\\/\/\/\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(“| |(| | | | | | | | | | | | | | | | | | | | | |”)
打印(“| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 124
打印(“| |”)
打印(“| |”)
睡眠时间(0.7)
清除()
打印(“打印”)
打印(“\\/| |”)
打印(“\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(\/\\\\\\/\/\/\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(“| |(| | | | | | | | | | | | | | | | | | | | | |”)
打印(“| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 124
打印(“| |”)
打印(“| |”)
睡眠时间(0.7)
清除()
打印(“打印”)
打印(“\\/| |”)
打印(“\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(\/\\\\\\/\/\/\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
打印(“| | | | | | | | | | | | | | | | | | | | | | | |
打印(“| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 124
打印(“| |”)
打印(“| |”)
睡眠时间(0.7)
清除()
在main.py中使用的函数ascii.ywu_banner(2)之后,出现以下错误:

Press ENTER/RETURN on your keyboard to start the game
Traceback (most recent call last):
  File "main.py", line 102, in <module>
    init()
  File "main.py", line 26, in init
    START_INPUT = input("Press ENTER/RETURN on your keyboard to start the game")
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing
按键盘上的回车键开始游戏
回溯(最近一次呼叫最后一次):
文件“main.py”,第102行,在
init()
文件“main.py”,第26行,在init中
开始输入=输入(“按