F
F
fyfaa2021-06-27 21:19:28
Python
fyfaa, 2021-06-27 21:19:28

Random selection of .ttf files from a directory in Python?

The fact is that I am making a bot for a group whose direction lies in the fonts. Naturally, you need a lot of fonts. I would like to know how to choose 1 random font from the font catalog.
help

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Coder 1448, 2021-06-29
@fyfaa

import os
import random

fonts = os.listdir(‘папка со шрифтами’)
random_font = random.choice(fonts)

S
ScriptKiddo, 2021-06-27
@ScriptKiddo

import random

fonts = ['1.ttf', '2.ttf', '3.ttf']
font = random.choice(fonts)

J
Jalal Nasirov, 2021-06-28
@Best_Loops

from random import choice
fonts = ['file_1.ttf' , 'file_2.ttf' , 'file_3.ttf']
random = choice(fonts)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question