Skip to content
Related Articles
Open in App
Not now

Related Articles

Art module in Python

Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 12 Nov, 2020
Improve Article
Save Article

Art package is used to print decorative art’s on the terminal as well as to save in file and a word can be represented by ” | “and can be saved in a file

Installation

This module doesn’t come built-in with Python. To install this type the below command in the terminal. 

 pip install art 

Function:

  1. Printing Normal and random arts on terminal and aprint() function
  2. Printing a word in form of | and tprint() function also saving it in text/pdf file

Printing art on terminal:

Syntax: art ( name of art, number is integer denoting number of arts in string )

Python3




# import module
from art import *
  
# return multiple art as str
art__0=art("woman",number=10)
  
print(art__0)

Output: 

Random generation of arts:

Python3




from art import *
  
print(art("random"))

Output:

Using aprint() function

Here, you can directly print arts just like the print function you print something 

Python3




from art import *
  
  
print("Buttterfly by art :  ",end=" ")
  
aprint("butterfly")
print()

Output:

Now Let’s move towards the capability of python text to art 

Python3




# import module
from art import *
  
# Return ASCII text with block font
# If font=None then there is no block
Art = text2art("GFG", font='block', chr_ignore=True)
  
print(Art)

Output:

tprint() function is same as print() function it prints the text into ASCII format

Python3




# import module
from art import *
  
# random large text to art representation 
# This art will be random every time
tprint("GFG","rnd-xlarge")

Output:

We can save this to a txt file too by using tsave() function. 

Syntax: tsave(“STRING”, OUTPUT FILE NAME OR PATH)

Python3




# import module
from art import *
  
Filename = tsave(
    "GEEKSFORGEEKS", filename="Output_in_txt_file_using_tsave().txt")

Output:


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!