generate Lorem-text in python

How to generate Lorem-text in python?

0 / 0 4 Mins Admin

October 31, 2022


You can generate Lorem-text in python using different modules. In publishing and graphic design, Lorem ipsum is a placeholder text.

It is common to demonstrate the visual form of a document or a typeface without relying on meaningful content. 

Lorem ipsum may be helpful as a placeholder before the final copy is available. You can also use it to temporarily replace text in a process called greeking.

which allows designers to consider the form of a webpage or publication, without the meaning of the text influencing the design.

Lorem ipsum text is typically a corrupted version of “De finibus bonorum et malorum“, a 1st-century BC text by the Roman statesman and philosopher Cicero, with words altered, added, and removed to make it nonsensical and improper Latin.

Versions of the Lorem ipsum text have been used in typesetting at least since the 1960s when it was popularized by advertisements for Letraset transfer sheets.

 Lorem ipsum was introduced to the digital world in the mid-1980s when Aldus employed it in graphic and word-processing templates for its desktop publishing program PageMaker.

Other popular word processors, including Pages and Microsoft Word, have since adopted Lorem ipsum, as have many LaTeX packages, web content managers such as Joomla! and WordPress, and CSS libraries such as Semantic UI.

see also: How to create scroll indicator?

generate Lorem-text in python
generate Lorem-text in python

A simple example to generate lorem-text in python

Here is a very simple example that generates a sentence, paragraph, and some text for you.

# generate Lorem-text in python exapme
pip install lorem
# generate Lorem-text in python example

import lorem
s = lorem.sentence() 
p = lorem.paragraph()
t = lorem.text()


Generate lorem-text using lorem-text Python module.

It is simple to specify the length of words and paragraphs using this module. First, you need to install it.

pip install lorem-text
from lorem_text import lorem
s = lorem.sentence()
p = lorem.paragraph()

Compose many paragraphs of lorem ipsum text, each with two to four sentences:

paragraph_length = 5
p = lorem.paragraphs(paragraph_length)

You can also specify the number of words. For example, we can generate 20 words here.

words = 20
w = lorem.words(words)

Lorem ipsum example

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec venenatis velit ac enim tristique faucibus. Proin dapibus arcu eget massa convallis posuere malesuada vel sapien.

Aenean venenatis tortor nec pulvinar lobortis. Proin odio felis, luctus a vestibulum eu, aliquet eu odio. Integer auctor metus lectus, at consequat diam eleifend ac.