Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.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 为什么Spyder不会运行或调试我的代码?_Python_Python 3.x_Debugging_Spyder_Ipdb - Fatal编程技术网

Python 为什么Spyder不会运行或调试我的代码?

Python 为什么Spyder不会运行或调试我的代码?,python,python-3.x,debugging,spyder,ipdb,Python,Python 3.x,Debugging,Spyder,Ipdb,我是一个初学者,在Spyder上使用Python3.7,当我运行代码时,它会打开一个system32命令提示符,然后立即关闭。什么也没发生。当我尝试按下调试按钮时,也会发生同样的情况。我将把代码粘贴到这里。 编辑:多亏了oliverm,我已经更新了代码,但代码仍然不会启动 #-*-编码:utf-8-*- """ Spyder编辑器 这是一个临时脚本文件。 """ #进口 随机输入 #定义变量 学分=10 再次播放=无 杰克=10 女王=10 国王=10 ace=11#不错 x=0 y=0 a=0

我是一个初学者,在Spyder上使用Python3.7,当我运行代码时,它会打开一个system32命令提示符,然后立即关闭。什么也没发生。当我尝试按下调试按钮时,也会发生同样的情况。我将把代码粘贴到这里。 编辑:多亏了oliverm,我已经更新了代码,但代码仍然不会启动

#-*-编码:utf-8-*-
"""
Spyder编辑器
这是一个临时脚本文件。
"""
#进口
随机输入
#定义变量
学分=10
再次播放=无
杰克=10
女王=10
国王=10
ace=11#不错
x=0
y=0
a=0
b=5
玩=真
CardAmount=0
甲板=[1,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,7,7,8,8,8,9,9,9,10,10,10,10,杰克,杰克,杰克,王后,王后,王后,国王,国王,国王,王牌,王牌,王牌,王牌,王牌,王牌,王牌,王牌,王牌,王牌,王牌]
#定义函数
def问候语():
打印(“您好!欢迎玩21点!d\您想玩吗?”)
打印(“是或否”)
答案=输入()
如果答案==“是”或“是”或“y”或“y”:
二十一点
elif答案==“否”或“否”或“n”或“n”:
打印(“好吧,祝你愉快!”)
其他:
打印(“我不知道你刚才说了什么。你能再试一次吗?”)
返回
def bets():
打印(“您将赌多少?”)
打印(“您有”,信用,“信用”)
bet=int(输入())
打印(“好吧!让我们开始吧!”)
通过
def playerplay():
card1=随机选择(组)
card2=随机选择(牌组)
#这里是王牌逻辑。if语句。
卡片列表=[card1,card2]
如果card1==ace和card2==ace:
pastace=2
card1=1
card2=11
elif card1==ace:
pastace=1
如果卡片2+11>21:
ace=1
其他:
ace=11
elif card2==ace:
pastace=1
如果卡1+11>21:
ace=1
其他:
ace=11
其他:
pastace=0
通过
cardamont=card1+card2
打印(“你画了一张”,卡片1,“和一张”,卡片2)
播放时==真:
打印(“您当前拥有”,CardAmount,“积分”,pastace,“aces”)
打印(“击中还是站立?”)
hvalue=str(输入())
如果hvalue=='Hit'或“Hit”或“H”或“H”:
卡片列表。追加(随机。选择(卡片组))
#计算卡达蒙特
对于y in len(卡片列表):
CardAmount+=cardlist[y]
如果y==len(卡片列表):
y=0
打破
其他:
y+=1
#在这里粘贴ace逻辑
如果卡片列表[x+1]==ace:
pastace+=1
如果CardAmount>21且pastace==1:
ace=1
cardamont==card1+card2
对于y in len(卡片列表):
CardAmount+=cardlist[y]
如果y==len(卡片列表):
y=0
打破
其他:
y+=1
如果CardAmount>21:
打印(“您已抽出超过21张牌。现在庄家将开始玩。”)
播放=错误
del cardlist[0:x]
pcardamount=cardammount
pastace=0
x=0
通过
其他:
x+=1
返回
elif CardAmount>21和pastace>1:
ace=1
cardamont=card1+card2
对于y in len(卡片列表):
CardAmount+=cardlist[y]
如果y==len(卡片列表):
y=0
打破
其他:
y+=1
如果CardAmount>21:
打印(“您已抽出超过21张牌。现在庄家将开始玩。”)
播放=错误
del cardlist[0:x]
pastace=0
pcardamount=cardammount
x=0
通过
elif CardAmount-22>-11:
卡片列表中的ace=11
返回
其他:
x+=1
返回
其他:
x+=1
返回
elif hvalue==“支架”或“支架”或“S”或“S”:
打印('好的!您的卡总数量为',卡总数量)
播放=错误
del cardlist[0:x]
pastace=0
pcardamount=cardammount
x=0
通过
其他:
打印(“对不起,你说了什么?”)
返回
定义结果():
打印(“您的卡总数量为”,pcardamount,“经销商的卡总数量为”,dcardamount)
如果PCARDAMOUNT>DCARDAMOUNT和PCARDAMOUNT 21:
del cardlist[0:x]
pastace=0
x=0
dcardamount=cardammount
CardAmount=0
通过
其他:
x+=1
返回
elif CardAmount>21和pastace>1:
ace=1
cardamont=card1+card2
对于y in len(卡片列表):
CardAmount+=cardlist[y]
如果y==len(卡片列表):
y=0
打破
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
#imports
import random
import ipdb
#def the vars
credits = 10
playagain = None
jack = 10
queen = 10
king = 10
ace = 11 #Nice
x = 0
y = 0
a = 0
b = 5
playing = True
cardammount = 0
deck = [1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,jack,jack,jack,jack,queen,queen,queen,queen,king,king,king,king,ace,ace,ace,ace]
# def the functions


def greetings():
    ipdb.set_trace()
    print("Greetings! Weclome to Blackjack! \n Do you wish to play?")
    print("Yes or No")
    answer = input()
    if answer in ["Yes", "yes", "y", "Y"]:
        blackjack()
    elif answer in ["No", "no", "n", "N"]:
        print("Alright then. Have a good day!")
        return
    else:
        print("I have no idea what you just said. can you try that again?")
        return


def bets():
    print("How much will you bet?")
    print("You have ", credits, " credits")
    bet = int(input())
    print("Alright! Lets start!")
    return bet


def playerplay():
    card1 = random.choice(deck)
    card2 = random.choice(deck)
    #ace logic here. an if statement.
    cardlist = [card1, card2]
    if card1 == ace and card2 == ace:
        pastace = 2
        card1 = 1
        card2 =11
    elif card1 == ace:
        pastace = 1
        if card2 + 11 > 21:
            ace = 1
        else:
            ace = 11
    elif card2 == ace:
        pastace = 1
        if card1 + 11 > 21:
            ace = 1
        else:
            ace = 11
    else:
        pastace = 0
        pass
    cardammount = card1 + card2
    print ("You drew a ", card1, " and a ", card2)
    while playing == True:
        print ("You currently have ", cardammount, " points with ", pastace, "aces" )
        print ("Hit or Stand?")
        hvalue = str(input())
        if hvalue == 'Hit' or "hit" or "H" or "h":
            cardlist.append(random.choice(deck))
            #calculates cardammount
            for y in len(cardlist):
                cardammount += cardlist[y]
                if y == len(cardlist):
                    y = 0
                    break
                else:
                    y += 1
            #paste ace logic here
            if cardlist[x + 1] == ace:
                pastace += 1
            if cardammount > 21 and pastace == 1:
                ace = 1
                cardammount == card1 + card2
                for y in len(cardlist):
                    cardammount += cardlist[y]
                    if y == len(cardlist):
                        y = 0
                        break
                    else:
                        y += 1
                if cardammount > 21:
                    print("You have drawn over 21 cards. Now the dealer will play.")
                    playing = False
                    del cardlist[0:x]
                    pcardammount = cardammount
                    pastace = 0
                    x = 0
                    pass
                else:
                    x += 1
                    return
            elif cardammount > 21 and pastace > 1:
                ace = 1
                cardammount = card1 + card2
                for y in len(cardlist):
                    cardammount += cardlist[y]
                    if y == len(cardlist):
                        y = 0
                        break
                    else:
                        y += 1
                if cardammount > 21:
                    print("You have drawn over 21 cards. Now the dealer will play.")
                    playing = False
                    del cardlist[0:x]
                    pastace = 0
                    pcardammount = cardammount
                    x = 0
                    pass
                elif cardammount - 22 > -11:
                    ace in cardlist == 11
                    return
                else:
                    x += 1
                    return
            else:
                x += 1
                return
        elif hvalue == 'Stand' or 'stand' or 'S' or "s":
            print ('Alright! Your total card ammount is ', cardammount)
            playing = False
            del cardlist[0:x]
            pastace = 0
            pcardammount = cardammount
            x = 0
            pass
        else:
            print ("I'm sorry. What did you say?")
            return
def outcome():
    print("Your total card ammount was", pcardammount, "and the dealer's was ", dcardammount)
    if pcardammount > dcardammount and pcardammount <= 21 :
        print("You win!")
        credits += bet*2

    elif pcardammount < dcardammount and dcardammount <=21 :
        print("You lose...")
        credits -= bet
    else:
        print("It's a tie!")
    #says who wins here and defines playagain
    playing = True
    print("You now have ", credits, " credits.")
    print ("Do you wish to play again?")
    answer2 = str(input())
    if answer2 in ["Yes", "yes", "y", "Y"]:
        blackjack()
    elif answer2 in ["No", "no", "n", "N"]:
        print("Alright then. Have a good day!")
        return
    else:
        print("I have no idea what you just said. can you try that again?")
        return

def hit():
    cardlist.append(random.choice(deck))
    #calculates cardammount
    for y in len(cardlist):
        cardammount += cardlist[y]
        if y == len(cardlist):
            y = 0
            break
        else:
            y += 1
    #paste ace logic here
    if cardlist[x + 1] == ace:
        pastace += 1
    if cardammount > 21 and pastace == 1:
        ace = 1
        cardammount == card1 + card2
        for y in len(cardlist):
            cardammount += cardlist[y]
            if y == len(cardlist):
                y = 0
                break
            else:
                y += 1
        if cardammount > 21:
            del cardlist[0:x]
            pastace = 0
            x = 0
            dcardammount = cardammount
            cardammount = 0
            pass
        else:
            x += 1
            return
    elif cardammount > 21 and pastace > 1:
        ace = 1
        cardammount = card1 + card2
        for y in len(cardlist):
            cardammount += cardlist[y]
            if y == len(cardlist):
                y = 0
                break
            else:
                y += 1
        if cardammount > 21:
            playing = False
            del cardlist[0:x]
            pastace = 0
            x = 0
            dcardammount = cardammount
            cardammount = 0
            pass
        elif cardammount - 22 > -11:
            ace in cardlist == 11
            return
        else:
            x += 1
            return
    else:
        x += 1
def dealerplay():
    card1 = random.choice(deck)
    card2 = random.choice(deck)
    #ace logic here. an if statement.
    cardlist = [card1, card2]
    if card1 == ace and card2 == ace:
        pastace = 2
        card1 == 1
        card2 ==11
    elif card1 == ace:
        pastace = 1
        if card2 + 11 > 21:
            ace = 1
        else:
            ace = 11
    elif card2 == ace:
        pastace = 1
        if card1 + 11 > 21:
            ace = 1
        else:
            ace = 11
    else:
        pastace = 0
        pass
    cardammount = card1 + card2
    if cardammount < 17:
        hit()
        return
    else:
        del cardlist[0:x]
        pastace = 0
        x = 0
        dcardammount = cardammount
        cardammount = 0
        pass
def blackjack():
    bets()
    playerplay()
    dealerplay()
    outcome()

#game functions put together
greetings()