파이썬

파이썬 변수전달하기

by nanumi posted Sep 05, 2021
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

 

 

 

class Main():
    def __init__(self):
        super().__init__()
        print("Kiwoom() class 시작합니다.")


        self.출력="출력이 될까요?"
        temp = self.test_print()
        print(temp)


    def test_print(self):
        temp=(self.출력)
        return temp

Main()

 

하단에

Main()

 

class Main():

을 호출하고

 

self.출력 변수에 "출력이 될까요?"데이터를 는다.

 

temp = self.test_print()

temp 변수에  self.test_print()  함수의 return 값을 보관한다.

 

 

print(temp)

저장된 temp의 내용을 출력한다.

 

 

 

    def test_print(self):
        temp=(self.출력)
        return temp

test_print(self) 에서는

self.출력에 담긴 내용을 temp 저장한다.

temp를 전달해준다.

 

 

정상출력이 잘되네요.

 

 


Articles

1 2 3 4 5