python how to import modules code example

Example 1: import different module based on python version

try:
    import simplejson as json
except ImportError:
    import json

Example 2: importing modules with package in python

from pakage_name.module_name import function_name
# now we can directly use function

##################################  OR  ########################################

from pakage_name import module_name
# now we have to use module_name.function_name

Example 3: modules in python

import  pandas as pd:

Example 4: How import a module in python

import mymodule #Ex : tkinter, turtle, etc...
#If you want import a module who isn't in Python (PyGame, QWidgets)
#and you have PyCharm, write : "pip install mymodule", wait the installation
#and write in interpreter : import mymodule, for other ide, search on 
#forums