第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

TypeError:無法將‘int’對象隱式轉(zhuǎn)換為str

TypeError:無法將‘int’對象隱式轉(zhuǎn)換為str

qq_遁去的一_1 2019-07-08 12:42:36
TypeError:無法將‘int’對象隱式轉(zhuǎn)換為str我正在嘗試寫一個文字游戲,我在我定義的函數(shù)中遇到了一個錯誤,這個函數(shù)讓你在完成角色后基本上可以使用你的技能點。首先,錯誤聲明我試圖從代碼的這一部分中的整數(shù)中減去一個字符串:balance - strength..顯然那是錯誤的,所以我用strength = int(strength)..但是現(xiàn)在我得到了這個錯誤,這是我以前從未見過的(新程序員),我很困惑它到底想告訴我什么,以及我是如何修復它的。下面是函數(shù)中不起作用的部分的代碼:def attributeSelection():     balance = 25     print("Your SP balance is currently 25.")     strength = input("How much SP do you want to put into strength?")     strength = int(strength)     balanceAfterStrength = balance - strength    if balanceAfterStrength == 0:         print("Your SP balance is now 0.")         attributeConfirmation()     elif strength < 0:         print("That is an invalid input. Restarting attribute selection. Keep an eye on your balance this time!")         attributeSelection()     elif strength > balance:         print("That is an invalid input. Restarting attribute selection. Keep an eye on your balance this time!")         attributeSelection()     elif balanceAfterStrength > 0 and balanceAfterStrength < 26:         print("Ok. You're balance is now at " + balanceAfterStrength + " skill points.")     else:         print("That is an invalid input. Restarting attribute selection.")         attributeSelection()有人道怎么解決這個問題嗎?先謝了。
查看完整描述

2 回答

?
慕斯709654

TA貢獻1840條經(jīng)驗 獲得超5個贊

def attributeSelection():balance = 25print("Your SP balance is currently 25.")strength = input("How much SP do you want to put into strength?")
balanceAfterStrength = balance - int(strength)if balanceAfterStrength == 0:
    print("Your SP balance is now 0.")
    attributeConfirmation()elif strength < 0:
    print("That is an invalid input. Restarting attribute selection. Keep an eye on your balance this time!")
    attributeSelection()elif strength > balance:
    print("That is an invalid input. Restarting attribute selection. Keep an eye on your balance this time!")
    attributeSelection()elif balanceAfterStrength > 0 and balanceAfterStrength < 26:
    print("Ok. You're balance is now at " + str(balanceAfterStrength) + " skill points.")else:
    print("That is an invalid input. Restarting attribute selection.")
    attributeSelection()


查看完整回答
反對 回復 2019-07-08
  • 2 回答
  • 0 關(guān)注
  • 577 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號