Seite 1 von 1

Anfängerfrage: Tabs

Verfasst: Dienstag 22. Juni 2010, 18:57
von bjoernh
Hallo Leute,
Ich habe eine Text mit tab-getrennten Einträgen, etwa so:

Code: Alles auswählen

hallo1\thallo2\thallo3
Wie kann ich die einzelnen Einträge in separate Variablen auslesen?

Re: Anfängerfrage: Tabs

Verfasst: Dienstag 22. Juni 2010, 19:00
von Barabbas
Hallo!

Das geht genau so, wie auch bei anderen Strings (mit split()):

Code: Alles auswählen

>>> txt = "hallo1\thallo2\thallo3"
>>> txt.split("\t")
['hallo1', 'hallo2', 'hallo3']
Schönen Gruß,

brb

Re: Anfängerfrage: Tabs

Verfasst: Dienstag 22. Juni 2010, 19:03
von bjoernh
Cool, klappt.