Friday, 22 September 2017

How to use Python modules in programs ?


IMPORTING MODULE
from <pkg> import <module>

# Using module under package

from openpyxl import workbook

# Direct module usage
import calendar



PRINTING MODULES OF A PACKAGE
# Prints all modules + sys vars of package openpyxl
import openpyxl
print(dir(openpyxl)


import calendar
print(dir(calendar))


# Prints all functions available in String
name="Orange"
print(dir(name))
 

# Prints all functions available in integer
val=50
print(dir(val))


No comments:

Post a Comment

Note: only a member of this blog may post a comment.