python中出現'>=' not supported between instances of 'str' and 'int'錯誤


提示錯誤為: TypeError: '>=' not supported between instances of 'str' and 'int'
因為 input 接收到的都是字符串類型,解決方案是轉變字符類型。
score=int(input ("請輸入你的成績:"))
if score >= 90:
print('優秀')
elif score < 90 and score>=80:
print('良好')
elif score < 80 and score>=60:
print('及格')
else:
print('不及格')


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM