tm.py
def hello():
print("test success")
tmtest.py
import tm
tm.hello()
tm.py에 테스트할 함수를 만들고 tmtest.py에 import로 불러온 함수이다.
파일명.함수명(파일명 안에 있는)으로 사용할 수 있다.
파일명.함수명 말고 함수명만 쓰는법 ex) tn.hello() ->hello()
from 파일명 import * 파일명에 있는 모든 걸 가져오겠다는 뜻이고
from 파일명 import 가져올 함수명 으로도 사용할수 있지만 추천하지는 않는다. 다른 폴더에서도 가져오기 시작하면 헷갈릴 수도 있다.
파일명이 길땐 as를 사용하면 된다.
ex) tm 대신 a로 바꿈
import tm -> import tm as a
tm.hello() -> a.hello()
import test1.test2.module --normaltic study 7주차--