A
A
Alpharius_Prog2022-04-05 21:08:19
Python
Alpharius_Prog, 2022-04-05 21:08:19

How to create an array from text files?

Found an article about pagination. There was mentioned an array of texts that became the basis for the bot.
How to convert text files into an array for subsequent import for a telegram bot?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gd1xza, 2022-04-05
@gd1xza

give a link to the article.
how to understand array of texts?
no data type - text
can array of strings?

How to convert text files into an array for subsequent import for a telegram bot,

what does it mean to convert text files to an array?
what is a text file? lines separated by a carriage return? or some other abstraction?
if the text file is large enough and/or there are many of them, then it is not profitable to store them as strings in an array inside the memory because it is not rubber.

Y
YelKa, 2022-04-06
@YelKa

Well, I didn’t even understand what was needed from the article, but if you need to convert a text file to an array line by line, then

with open("file.txt") as file:
    l = file.readlines()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question