原文:python當出現 not supported between instances of 'str' and 'int' 的處理方法

當我們編程時,有時會出現如下錯誤:TypeError: gt not supported between instances of str and int str : 字符串 int :整型 如下圖: 這是因為input 返回的數據類型是str類型,不能直接和整數進行比較,必須先把str轉換成整型,使用int 方法:age int input 請輸入你的年齡: 改正之后為: ...

2019-02-10 10:38 0 2105 推薦指數:

查看詳情

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