0
string='I love #Snorlax he is a beast #op#letsgo'
for item in string.split():
if item.startswith('#'):
print(item)
我的代碼的問題是,輸出我得到的是:Occurence串的Python
#Snorlax
#op#letsgo
輸出應該
#Snorlax
#op
不,這是*不是您發佈的代碼的輸出。你可能忘了分割'string'。 –