Answer the question
In order to leave comments, you need to log in
How to make a Python script to insert a random line from a txt file anywhere?
We need a script that, when run, would insert a random line from a txt file to a given location. That is, the script is assigned to a hot key using a special program (I have such a program, I only need a script), the execution of this script starts and random text from the txt file is inserted into any place - a field on the site, a text editor, and so on. You can not random, but sequential. Those. at the first insertion the 1st row, at the second the 2nd, it will be even better.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Here's roughly:
import random
File_text = open('file.txt', 'r').readlines()
random_text = random.choice(File_text)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question