簡體   English   中英

如何在終端中運行 python 程序並讓它顯示錯誤?

[英]How do I run a python program in terminal and get it to display errors?

我正在用 python 制作一個沒有 pygame 的游戲,需要在終端中運行。 當我在終端中運行代碼時,它會短暫打開,但時間不足以讓我看到錯誤。 這是我嘗試運行的代碼的一部分,但它不輸出任何內容,而只是關閉。 這意味着我無法找出我的代碼有什么問題。 當我通過命令提示符運行它時,它沒有給出任何輸出或錯誤

from time import sleep

def screenArray():
    screen = []
    for row in range(40):
        screenRow = []
        for column in range(99):
            screenRow.append("-")
        screen.append(screenRow)
    print(screen)
    return screen

def playerToArray(screen, playercoords):
    x = playercoords[0]
    y = playercoords[1]
    print(screen[x,y])
    screen[x,y] = "O"
    return screen

playercoords = [20,50]
print(playerToArray(screenArray(),playercoords))
sleep(10)

我正在用 python 制作一個沒有 pygame 的游戲,需要在終端中運行。 當我在終端中運行代碼時,它會短暫打開,但時間不足以讓我看到錯誤。 這是我嘗試運行的代碼的一部分,但它不輸出任何內容,而只是關閉。 這意味着我無法找出我的代碼有什么問題。 當我通過命令提示符運行它時,它沒有給出任何輸出或錯誤

from time import sleep

def screenArray():
    screen = []
    for row in range(40):
        screenRow = []
        for column in range(99):
            screenRow.append("-")
        screen.append(screenRow)
    print(screen)
    return screen

def playerToArray(screen, playercoords):
    x = playercoords[0]
    y = playercoords[1]
    print(screen[x,y])
    screen[x,y] = "O"
    return screen

playercoords = [20,50]
print(playerToArray(screenArray(),playercoords))
sleep(10)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM