我正在尝试从文本文件中提取一组字母数字字符。
下面将是文件中的一些行。我想提取“@”以及随后的任何内容。
我试图从文件中提取@bob。这是@file 中的@line @bob 是个奇怪的东西
下面的代码是我到目前为止所拥有的。
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()
我想要得到的是;['@bob','@line','@file','@bob']