How to write text into a file with different font-sizes using Python?

How to write Text into a File using Python, where different parts of the Text has different font-size (Title, Sub-Title, content). How to place a picture in the file using Python?

Answers


Python is a programming language capable of manipulating text as variables. It does not provide a graphics engine to achieve what you are asking.

You need to decide which output format you want your file to be in, example: .html and then format the output as such.

For example, you can create a python file in html like this:

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()

Next, navigate to your folder and open test.html in any browser.

As for the images, I suggest you go to:

[1]: http://www.w3schools.com/html/html_images.asp

Good luck!


Need Your Help

C#: How Should I Handle Arithmetic with Huge Numbers?

c# .net string biginteger

I'm writing an app which involves arithmetic with humongous numbers, with very many digits. I've previously written a class that simplifies handling big numbers by defining them as strings and then...