![](/img/trans.png)
[英]How do you grab specific "font-sizes" while ignoring others using BeautifulSoup in Python?
[英]How to write text into a file with different font-sizes using Python?
如何使用 Python 將文本寫入文件,其中文本的不同部分具有不同的字體大小(標題、副標題、內容)。 如何使用 Python 在文件中放置圖片?
Python 是一種能夠將文本作為變量進行操作的編程語言。 它不提供圖形引擎來實現您的要求。
您需要決定您希望文件采用哪種輸出格式,例如:.html,然后將輸出格式設置為這樣。
例如,您可以像這樣在 html 中創建一個 python 文件:
file_handle = open("test.html", "w+b")
html = "<h1>I am a big header</h1><h2>I am a smaller header</h2><h6>I am the smalles header</h6>"
file_handle.write(html)
file_handle.close()
接下來,導航到您的文件夾並在任何瀏覽器中打開 test.html。
至於圖片,我建議你去:
[1]:http://www.w3schools.com/html/html_images.asp
祝你好運!
對於文本,我會寫出不同的行,嘗試使用烏龜:
h1 = 10
txt = 5
turtle.write('<example',font('Arial,h1,'normal')
等等等等。 至於圖片,我不知道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.