lundi 19 juin 2017

combining items from list to first underscore

Let's say I have a file(.txt) with:

footest_footest1
footest_footest2
footest_footest3
bartest_bartest1
bartest_bartest2
cartest_cartest1
cartest_cartest2
cartest_cartest3

Using python, how could I aggregate events to the first underscore so it prints:

footest
bartest
cartest

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire