0

Hey,

I am new to python and was wondering how to import modules?
I want to import the datetime module. Do i have to download it from a website?

Thanks

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by vegaseat
0

datetime module is standard, just import it in begining of your program with

import datetime

Have you tried to search this forum for "date time python"? There is much usefull information here like this

Edited by pyTony: n/a

0

Some practical considerations ...

# import all functions in module
import module1
# call function func1()
module1.func1()

# import all functions in module, but use a substitute name
import module1 as md
md.func1()

# import specified function in module
from module1 import func1
# call func1
func1()

# import specified function in module, but use a substitute name
from module1 import func1 as f1
f1()

# import all functions in module into the present namespace
# use sparsely, beware of name clashes with other functions
# (does not allow access to module variables)
from module import *  


# list all the modules Python currently knows about ...
help("modules")
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.