Python Textwrap Module
Text wrapping — wrap, fill, dedent, indent, shorten. This category documents 5 Python textwrap module entries, and each page gives you the full syntax, the parameter list, the return value, and a runnable example. The entries include: textwrap.wrap(), textwrap.fill(), textwrap.dedent(), textwrap.indent(), textwrap.shorten(). textwrap.wrap() wraps text into a list of lines, each at most `width` characters. textwrap.fill() similar to wrap() but joins the lines with newlines and returns a single string. textwrap.dedent() removes common leading whitespace from all lines (for multiline strings). textwrap.indent() adds a prefix to the beginning of selected lines. textwrap.shorten() truncates text to fit within `width` characters, adding a placeholder. Textwrap Module belongs to the Text & Regex group alongside Regex Module, Difflib Module, Unicodedata Module, HTML Module. You can also search across every category from the search page, browse the complete A–Z index, or try any example in the Python playground.