我想在第二個位置中發現.
之後放置<br>
,如下所示。如何將br標籤放在第二個位置的點後
str = "Lorem ipsum amet. consectetur adipisicing elit. sed do eiusmod magna aliqua. Ut enim ad minim veniam. Lorem ipsum amet. consectetur adipisicing elit. sed do eiusmod magna aliqua. Ut enim ad minim veniam."
預計業績:
str = "Lorem ipsum amet. consectetur adipisicing elit. <br> sed do eiusmod magna aliqua. Ut enim ad minim veniam. Lorem ipsum amet. <br> consectetur adipisicing elit. sed do eiusmod magna aliqua. <br> Ut enim ad minim veniam."
我嘗試使用這個腳本:
s = "During a November 2014 trip to Los Angeles. Boston-based Snapchat creator. Mike Platco stopped by Snap's Venice. CA offices to say hello."
index = [i for i,c in enumerate(s) if c=='.']
data = []
for x in index:
text = s[:x*2].replace('. ', '. <br>')
data.append(text)
print data
結果:
['During a November 2014 trip to Los Angeles. <br>Boston-based Snapchat creator. <br>Mike Plat', "During a November 2014 trip to Los Angeles. <br>Boston-based Snapchat creator. <br>Mike Platco stopped by Snap's Venice. <br>CA offices to say hello.", "During a November 2014 trip to Los Angeles. <br>Boston-based Snapchat creator. <br>Mike Platco stopped by Snap's Venice. <br>CA offices to say hello.", "During a November 2014 trip to Los Angeles. <br>Boston-based Snapchat creator. <br>Mike Platco stopped by Snap's Venice. <br>CA offices to say hello."]
那麼你有什麼嘗試,究竟是什麼問題呢? – jonrsharpe
@jonrsharpe我仍然困惑,試試看。希望在這裏我可以找到一種方法來處理這種情況。 –
這不是一個代碼寫作或教程服務。參加[遊覽],學習[問]。 – jonrsharpe