SoFunction
Updated on 2024-11-21

settle (a dispute)Python exceptionsTypeError: cannot concatenate 'str' and 'int' objects

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

This is what happens when you print str + int

python + as a concatenator does not automatically convert int to str for you

Additional knowledge:TypeError: cannot concatenate 'str' and 'list' objectscap (a poem)Python读取cap (a poem)保存图片

Running the program times an error, then I just convert list to str.

Utilizing ''.join(list)

If you need to separate by comma, such as 1,2,3,4 then use ','.join(list)

Python plt can display and save images, can't use mping

import as mpimg # mpimg for reading images

At the beginning of the import, add

import as plt

from PIL import Image

Open with open('path')

Save with ('path')

The above article to solve the Python exception TypeError: cannot concatenate 'str' and 'int' objects is all I have to share with you, I hope to be able to give you a reference, and I hope that you will support me more.