Hello, I'm Yeoreum In who is studying automation by himself.
I'd like to turn around some simple Python files on Python, but is there any way to turn Python on Python?
file
Oh, that's what you meant<
Inside the folder where the current shell is running
There are hello1.py, hello2.py, hello3.py...
When you want to run all those files...
The simplest and fastest way to do it is to do it
from glob import glob
File list = glob("*.py")
For File in File List:
exec (file).read())
Another way is to do this:
import subprocess
from glob import glob
File list = glob("*.py")
For File in File List:
subprocess.call (['python', file])
The method below can also be implemented
from glob import glob
File list = glob("*.py")
For File in File List:
exec("import {}".format (file.split(".)[0])
Instead, this will be an error when there is a spacing or special character in the file name;
(If you're not talking about pypy)
There are several ways to run Python.
Largely
Simply run the py file as > python filename.py
on the command line,
How to turn from IDE such as PiCham or Jupiter laptop through RUN command,
Create an exe file through pyinstaller, etc. and double-click in the navigation pane to run
and so on
I think there are various ways.
I wonder if it was able to answer it
© 2025 OneMinuteCode. All rights reserved.