متغیرها در ماژول(Variables in Module)

ماژول می تواند دارای توابعی باشد، همانطور که قبلاً توضیح داده شد، اما همچنین متغیرهایی از
همه انواع (آرایه ها، دیکشنری ها، اشیاء و غیره):




مثال


Save this code in the file mymodule.py



person1 = {
  "name": "John",
  "age": 36,
 
"country": "Norway"
}




مثال


Import the module named mymodule, and access the person1 dictionary:



import mymodule

a = mymodule.person1["age"]
print(a)











<اسکریپت>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1493883843099-0'); });