Running multiple .py within Python

Asked 2 years ago, Updated 2 years ago, 20 views

C:\Users\Lion\PycharmProjects\1\makepng Inside the folder named

makepng1.py

makepng2.py

makepng3.py

makepng4.py

makepng5.py

makepng6.py

makepng7.py

makepng8.py

It contains Python files.

When executed,

image file to deal with ' lion users \ \ c png pycharmprojects maker in a folder png. _ \ 1 gif Each 1 to 8 to save them as png png code.

Is there a way to run these multiple Python codes sequentially within Python? For your information, I'm using Pi-Cham.

P.S

It doesn't come out well even if I google it.

Is there any order to run .gif on Python?

I made a .gif file with several images and saved it.

I can't read .gif in the imread of opencv2.

I can't help but double-click on the folder ㅠ<

python

2022-09-22 18:18

2 Answers

Think about it. We are already using a large number of Python files called modules.

That is, you can import the Python file and use the object.

In other words, you can import the python file 1 to 8 times and call the function.

If you do not know how to create and import modules, refer to Python tutorial (https://docs.python.org/ko/3/tutorial/modules.html)

gif is neither an executable nor a file with logic that can be executed

It is simply an image file in which binary data is stored (including formatting).

In other words, do not use the expression "execution".

opencv does not have a codec to encode/decode gif files.

Double-clicking directly in a folder does not mean it is available in opencv.

The gif file must use a different image processing module.

Imageio (https://imageio.github.io/) module to read and process the gif. imageio also returns to numpy array, so it fits well with opencv.

import imageio
import cv2

gif = imageio.mimread('8eai9oW.gif')
imgs = [cv2.cvtColor(img, cv2.COLOR_RGB2BGR) for img gif] #opencv stores color images as BGRs. Consequently, convert RGB order to BGR


2022-09-22 18:18

If you want to turn multiple Pythons sequentially, I think there is a way to import and there is a way to turn the subprocess.


2022-09-22 18:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.