文章詳情頁
python基礎(chǔ),數(shù)據(jù)類型問題
瀏覽:115日期:2022-07-24 17:26:53
問題描述
print type(-10)=='int'
上面的代碼為什么返回時 False?
type(-10) 是 整形數(shù)據(jù)啊。
問題解答
回答1:print(type(10) == int)True
你把 int 加上雙引號就變成 str 了, 當(dāng)然和 int 不一樣了。
回答2:不是這么玩的。。。
type(-10) is int
isinstance(-10,int)
排行榜

熱門標(biāo)簽