Python 3 detect and prevent TypeError-s

Publié le: 16 septembre 2018
sur la chaîne: Softhints - Python, Linux, Pandas
1,790
7

Python detect and prevent TypeError: sequence item 0 and join iterable

https://blog.softhints.com/python-det...

Errors:

* TypeError: sequence item 0: expected str instance, int found

and

* TypeError: can only join an iterable

Option 1

import collections
mylist = 2
if isinstance(mylist, collections.Iterable):
print(', '.join(mylist))

Option 2

try:
iterator = iter(mylist)
except TypeError:
print('not iterable')
else:
print(', '.join(mylist))


Sur cette page du site, vous pouvez voir la vidéo en ligne Python 3 detect and prevent TypeError-s durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Softhints - Python, Linux, Pandas 16 septembre 2018, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 1,790 fois et il a aimé 7 téléspectateurs. Bon visionnage!