I am trying to extract a set of alpha numeric characters from a text file.
below would be some lines in the file. I want to extract the '@' as well as anything that follows.
im trying to pull @bob from a file. this is a @line in the @file @bob is a wierdo
the below code is what I have so far.
def getAllPeople(fileName):
#give empty list
allPeople=[]
#open TweetsFile.txt
with open(fileName, 'r') as f1:
lines=f1.readlines()
#split all words into strings
for word in lines:
char = word.split("@")
print(char)
#close the file
f1.close()
What I am trying to get is; ['@bob','@line','@file', '@bob']