Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [espacios]Elnombre1[espacios](237)
- [espacios]Elnombre3(237)
- [espacios]Elnombre4(17)
- with open("e.txt", 'r+') as f:
- texto = re.sub('^s+([a-zA-Z-0-9]+)s*', f.read())
- f.seek(0)
- f.write(texto)
- f.truncate()
- nombres = []
- with open("e.txt", "r") as f:
- for linea in f:
- nombre = linea.split('(')[0].strip()
- nombres.append(nombre)
- with open("e.txt", "w") as f:
- for nombre in nombres:
- f.write("{}n".format(nombre))
- import re
- lineas = [
- ' Elnombre1 (237)',
- ' Elnombre3(237)',
- ' Elnombre4(17)'
- ]
- nombres = [re.findall('^s+([a-zA-Z-0-9]+)s*', x)[0] for x in lineas]
- print(nombres)
Add Comment
Please, Sign In to add comment