Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #5529
| From | Hermann Riemann <nospam.ng@hermann-riemann.de> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | Re: python2 --> python3 : str vs bytes |
| Date | 2019-08-25 10:20 +0200 |
| Message-ID | <gseum0F4hcoU1@mid.individual.net> (permalink) |
| References | <qjtf7q$p8s$1@news2.informatik.uni-stuttgart.de> |
Am 25.08.19 um 10:00 schrieb Ulli Horlacher:
> Die entsprechende Funktion sieht so aus:
> def despace(s):
> return ' '.join(s.split())
> Das soll (White-)Spaces am Anfang und Ende eines Strings entfernen und aus
> Multi-Spaces einen einzelnen machen.
> Mit Python 2 funktioniert das auch.
> Wieso liefert string.split() bytes zurueck und nicht wieder str?
Weil vermutlich string vorher vom type bytes war.
> Wie macht mans besser?
Mit print(type(s)) an einigen Stellen nachschauen
warum s nicht vom Typ str ( Buchstaben in utf ) ist
Hermann
vermutend, das iso utf Probleme noch Jahrzehnte
erhalten bleiben.
--
http://www.hermann-riemann.de
Back to de.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
python2 --> python3 : str vs bytes Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2019-08-25 08:00 +0000
Re: python2 --> python3 : str vs bytes Hermann Riemann <nospam.ng@hermann-riemann.de> - 2019-08-25 10:20 +0200
Re: [Python-de] python2 --> python3 : str vs bytes Stefan Behnel <python-de@behnel.de> - 2019-08-25 10:44 +0200
Re: [Python-de] python2 --> python3 : str vs bytes Hermann Riemann <nospam.ng@hermann-riemann.de> - 2019-08-26 07:03 +0200
csiph-web