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

解決Python 異常TypeError: cannot concatenate 'str' and 'int' objects

 更新時(shí)間:2020年04月08日 11:35:37   作者:叫我王員外就行  
這篇文章主要介紹了解決Python 異常TypeError: cannot concatenate 'str' and 'int' objects,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

TypeError: cannot concatenate 'str' and 'int' objects

print str + int 的時(shí)候就會(huì)這樣了

python + 作為連接符的時(shí)候,不會(huì)自動(dòng)給你把int轉(zhuǎn)換成str

補(bǔ)充知識(shí):TypeError: cannot concatenate 'str' and 'list' objects和Python讀取和保存圖片

運(yùn)行程序時(shí)報(bào)錯(cuò),然后我將list轉(zhuǎn)化為str就好了。

利用''.join(list)

如果需要用逗號(hào)隔開(kāi),如1,2,3,4則使用','.join(list)

Python中plt可以顯示和保存圖片,不能使用mping

import matplotlib.image as mpimg # mpimg 用于讀取圖片

開(kāi)頭import時(shí)加入

import matplotlib.pyplot as plt

from PIL import Image

打開(kāi)用open('路徑')

保存用a.save('路徑')

以上這篇解決Python 異常TypeError: cannot concatenate 'str' and 'int' objects就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論