파이썬 파일 간 변수호출
조회수 508회
원래 메인 1.py 파일에서 askopenfilename으로 사진을 불러오면 import cv2를 통해 filepath 변수를 2.py에서도 적용할 수 있게 하는 방법이 없을까여?
꼭 def 구문이라든지 if의 위치라든지 전체 틀을 하나도 깨지 않고 고쳐주세요!! (왜냐하면 원래는 코드가 더 많은데 생략한거라 틀은 그대로여야 합니다ㅠ)
#1.py
from tkinter.filedialog import *
def func_open():
filepath=askopenfilename(parent=window, filetypes=(("GIF 파일", "*.gif"),("모든파일", "*.*")))
import cv2
#2.py
import cv2
filepath = ?????
img = cv2.imread(filepath)
if __name__ == "__main__":
cv2.imshow('best out', best_out)
cv2.waitKey(0)
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력