Python 3 detect and prevent TypeError-s

Pubblicato il: 16 settembre 2018
sul canale di: 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))


In questa pagina del sito puoi guardare il video online Python 3 detect and prevent TypeError-s della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Softhints - Python, Linux, Pandas 16 settembre 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,790 volte e gli è piaciuto 7 spettatori. Buona visione!