0
作爲標題,在Python中檢索推文的第一個hashtag的代碼是什麼?如何檢索Python中tweet的第一個hashtag?
標籤輸出作爲一個字符串 tag= for tag in tw.split() if tag.startswith("#")}
作爲標題,在Python中檢索推文的第一個hashtag的代碼是什麼?如何檢索Python中tweet的第一個hashtag?
標籤輸出作爲一個字符串 tag= for tag in tw.split() if tag.startswith("#")}
使用正則表達式...
喜歡的東西
>>> tweet = 'some text #tagtag #anothertag'
>>> import re
>>> re.findall(r'\B\#\w+\b', tweet)
['#tagtag', '#anothertag']
使用https://www.regex101.com幫你捏捏正則表達式中
'[標籤爲標籤tw.split()if tag.startswith(「#」)] [0]'。 – Abdou