0
A
回答
0
你可以在一個更語義的方式做到這一點,與Tag.new_tag(..)
,Tag.clear()
和Tag.append()
:
atag = soup.a
atag.clear() # clear the content of the <a> tag
atag.append('support') # add the 'support' text
emtag = soup.new_tag('em') # create a new <em> tag
atag.append(emtag) # add the <em> tag to the <a> tag
emtag.string = '[6666]' # alter the text in the <em> tag
這種構造:
>>> soup
<html><body><a href="#" onclick="foo">support<em>[6666]</em></a></body></html>
在我的機器。
相關問題
- 1. 我無法更改PHP上的字符串編碼
- 2. 字符是字符串總是改變位置,當我通過使用CCLabelBMFont更改字符串值
- 3. 號碼自動更改爲字符串
- 4. 片段EditText.setText(字符串)字符串時,來自savedInstanceState但是當硬編碼
- 5. 當我們使用字符串而不是字符數組時,如何處理字符串的字符?
- 6. 更改字符串編碼WIN1250爲utf8
- 7. 我無法更改靜態無效主(字符串[]參數)
- 8. 創建我自己的字符串類/子字符串方法
- 9. 當串聯和Url編碼字符串時,Base-64字符串中的字符無效
- 10. 在編譯時更改字符串宏
- 11. 無法在字符串中更改WP值「the_title()」 - 字符串更改的順序
- 12. Javascript自動更改字符串
- 13. 當我打開字符串Unicode編碼時出現錯誤
- 14. 編碼 - Pydev自動更改字符
- 15. 編碼我的字符串通過C#
- 16. 編碼字符串
- 17. 給我使用字符串
- 18. 更改字符串
- 19. 字符串編碼,移動編碼
- 20. 當我使用變量而不是字符串文字時,Perl方法失敗
- 21. 使用Ruby 1.9字符串作爲字節流而不是編碼字符串
- 22. 當我無法預先知道字符編碼時,如何打印字符串列表?
- 23. Java - 修改我的字符串方法
- 24. Linq自動修剪我的字符串!
- 25. PHP自動解析我的字符串?
- 26. 指向字符串的指針無法更改字符
- 27. 我無法解析JSON字符串
- 28. 我如何編碼字符串中的所有字符
- 29. PHP BASE64_DECODE,無法確定我能夠使用phpbase64_decode功能如下字符串解碼解碼中的字符串
- 30. 當我使用Active Record時,可以將ID更改爲字符串嗎?
It works.Thank you very much! – AlphaGo