![](/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.