'Python for Everybody' Chapter 11 - Regular Expressions (Solved Exercises)

preview_player
Показать описание

Here is the code for the solutions:

Make sure to check out my other tutorial series on Django:

Follow me on
Рекомендации по теме
Комментарии
Автор

Thank you so much! I still learning but you definely were a great teacher

emiliogutierrez
Автор

wow the search method works better than findall method!! thank you so much!!!

stephaniegu
Автор

Q2 i tried by findall

hand = open('mbox short.txt')
for line in hand:
line = line.rstrip()
x=re.findall('^N.+: ([0-9]+)', line)
if len(x)>0:
print(x)

l.append(int(x))

here append(int(x)) is giving me error.

TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

nityanand_
Автор

but there are things he didn't explain

flaviobrienza