컴퓨터/Python

python 다른 파일에 id pw 저장 import 불러오기

풍경소리^^ 2020. 10. 30. 07:19

# file_a.py-----------------

# def my_idpw():

#     my_id="miero"

#     my_pw="1234"

#     return my_id,my_pw # tuple

# def my_id():

#     my_id="miero"

#     return my_id

# def my_pw():

#     my_pw="1234"

#     return my_pw

# ---------------------------

 

# *******************************

import file_a # import 파일명

 

a=file_a.my_idpw()[0] # tuple 파일.함수명()[첫번째]

b=file_a.my_idpw()[-1] # tuple 파일.함수명()[마지막]

print(a)

print(b)

 

c=file_a.my_id()

d=file_a.my_pw()

print(c)

print(d)

# *******************************

from file_a import my_id,my_pw # from 파일명 import 함수

 

c=my_id() # 함수명()

d=my_pw() # 함수명()

print(c)

print(d)