- 建立模板
- 只匯入自己所需要的功能或變數
建立模板
myclass1.py
def call_name(name):
print("hi"+name)
return True
dbname = "payment"
shop = {
"thing" : "pen",
"price" : 30,
"num" : 5
}
只匯入自己所需要的功能或變數
myclass5.py
#只匯入自己所需模板變數或功能
from myclass1 import shop
print(shop["num"])
print(shop["thing"])
或是
from myclass1 import call_name
x=call_name('John')
print(x)
Yiru@Studio - 關於我 - 意如