#python 3.6
#蔡军生
#http://blog.csdn.net/caimouse/article/details/51749579
#
import re
twitter = re.compile(
‘‘‘
# A twitter handle: @username
(?<=@)
([\w\d_]+) # username
‘‘‘,
re.VERBOSE)
text = ‘‘‘This text includes two Twitter handles.
One for @caimouse, and one for the author, @caijunsheng.
‘‘‘
print(text)
for match in twitter.findall(text):
print(‘Handle:‘, match)Handle: caijunsheng
原文:http://blog.csdn.net/caimouse/article/details/78492577