On 06/22/2017 09:14 PM, Gabriele Battaglia wrote: > Avvicinandomi a Python 3, ho qualche difficoltà ad afferrare il concetto > di tipo Byte. > Se doveste spiegarlo in parole semplice, cosa direste e/o quale risorsa > mi consigliereste di leggere?
In poche parole il tipo 'bytes' rappresenta le stringhe ASCII in Python 3. In Python 3 il tipo 'str' rappresenta stringhe Unicode ("le stringhe sono per default Unicode ..."), mentre in Python 2 'bytes' e 'str' erano lo stesso tipo, serviva per rappresentare stringhe ASCII, e c'era un tipo distinto per rappresentare stringhe Unicode (tipo 'unicode', che in Python 3 non c'è più). Verificando il tipo dei letterali stringa in Python 3: type(b'ciao') # <class 'bytes'> type('ciao') # <class 'str'> type(u'ciao') # <class 'str'> mentre in Python 2.7: type(b'ciao') # <type 'str'> type('ciao') # <type 'str'> type(u'ciao') # <type 'unicode'> -- _____________________________________________________ Davide Brunato SISSA - International School for Advanced Studies Information Technology and Computing Services via Bonomea 265 - 34136 Trieste - Italy tel: +39-040-3787538 e-mail: brun...@sissa.it web: http://itcs.sissa.it, http://www.sissa.it _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python