Answer the question
In order to leave comments, you need to log in
How to find the number of lines of similar text in a file?
Need help
Let's say there are a lot of IDs in the file, and I need to calculate the number of my id from the file when I command, here is a small code example
with open('README.txt','r') as file:
file = file.read()
for i in file:
if str(message.from_user.id) in i:
#Here count the number of lines of your id.
bot.reply_to(message,text='and here is the output of the count from the file')
and most importantly, who did not understand, I need NOT to find out the number of lines FROM THE FILE, but FIND out how many lines ID FROM THE FILE
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question