Open In App

Art module in Python

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 )




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

Output: 

Random generation of arts:




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

Output:

Using aprint() function

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




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

Output:

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




# 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




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




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

Output:


Article Tags :