How to Access Variables in Module in Python


In this example we will show how to access the variables in module in Python.

Source Code

import mymodule

'''
The contents of the module named mymodule:
student1 = {
    'name': 'Jim',
    'age': 15,
    'id': 16
}
'''

name1 = mymodule.student1['name']
print(name1)

Output:

Jim
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments