Answer the question
In order to leave comments, you need to log in
How can I make the script get the path to the file when dragging a file onto the script?
Conventionally, there is a main.py file and next to it in the same test.txt folder.
I drag test.txt onto main.py and it runs with the path to the test.txt file.
I saw a similar topic, but the exe file was compiled there.
Tried to write:
import sys
print(sys.argv[1])
input()
Answer the question
In order to leave comments, you need to log in
I found a solution, the error was that I opened the file using the interpreter:
C:\Python\Python39\python.exe
And I had to open it with the python launcher -a
C:\Windows\py.exe
Thanks Gennady S for help
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question