欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解決python錯(cuò)誤提示:TypeError: expected string or bytes-lik問(wèn)題

 更新時(shí)間:2024年01月29日 15:17:11   作者:K_Lily  
這篇文章主要介紹了解決python錯(cuò)誤提示:TypeError: expected string or bytes-lik問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

python錯(cuò)誤提示:TypeError: expected string or bytes-lik

python錯(cuò)誤提示:TypeError: expected string or bytes-like object(預(yù)定的數(shù)據(jù)類(lèi)型或者字節(jié)對(duì)象相關(guān))

一般為數(shù)據(jù)類(lèi)型不匹配造成的。

Python3有六個(gè)標(biāo)準(zhǔn)的數(shù)據(jù)類(lèi)型

  • Number(數(shù)字)
  • string(字符串)
  • List(列表)
  • Tuple(元組)
  • Sets(集合)
  • Dictionary(字典)

可以通過(guò)print(type(object))來(lái)查當(dāng)前的數(shù)據(jù)類(lèi)型,式中object為要查詢(xún)的對(duì)象。

解決辦法

轉(zhuǎn)換成字符串類(lèi)型

object = str(object)

python常見(jiàn)錯(cuò)誤 TypeError: 'NoneType' object is not iterable

TypeError: 'NoneType' object is not iterable

1. 將None賦給多個(gè)值時(shí),會(huì)出現(xiàn)提示:TypeError: 'NoneType' object is not iterable

2. 函數(shù)返回值一定要考慮到條件分支的覆蓋

3. 在沒(méi)有return語(yǔ)句時(shí),python默認(rèn)會(huì)返回None(return返回?cái)?shù)據(jù)為空)

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論