亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

python 3.6.6輸入不從輸入返回任何內容

python 3.6.6輸入不從輸入返回任何內容

元芳怎么了 2021-10-10 13:40:22
我的代碼目前非常簡單#BlackJackprint("welcome to Wasteful's blackjack game")`print("this program was built using standard python")print("please select a option")print("A to start, B to quit")print("----------------------------")menu_select = input("A/B: ").lowerif menu_select == "a":    print("starting game when i can be assed to program it")elif menu_select == "b":    exit()else:    print("invalid")但它對兩者a和b?都返回空白?我被卡住了,可以使用一些幫助,謝謝!編輯:我注意到 .lower 中的愚蠢錯誤應該是 .lower()
查看完整描述

2 回答

?
精慕HU

TA貢獻1845條經驗 獲得超8個贊

def main():

    print("welcome to Wasteful's blackjack game") 

    print("this program was built using standard python")

    print("please select a option") 

    print("A to start, B to quit")

    print("----------------------------")

    menu_select = input("A/B: ").lower()


    if (menu_select == "a"):

        print("starting game when i can be assed to program it") 


    elif (menu_select == "b"):

        exit() 


    else: 

        print("invalid")


main()

首先就像 rassar 說的,你必須在你從用戶那里得到你的輸入之后調用 .lower() 。接下來,我總是發現創建一個主循環函數來調用所有未來的函數并保持代碼漂亮整潔更容易!希望這會有所幫助!快樂編碼!:)


查看完整回答
反對 回復 2021-10-10
?
楊__羊羊

TA貢獻1943條經驗 獲得超7個贊

這是因為你不打電話lower(),你設置menu_select的函數本身:


>>> menu_select = input("? ").lower

>>> menu_select

<built-in method lower of str object at 0x10ca5eab0>

將您的線路更改為:


menu_select = input("A/B: ").lower()


查看完整回答
反對 回復 2021-10-10
  • 2 回答
  • 0 關注
  • 214 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號