Python
Python
• Packages
• File Handles
• Date and Time operations
• Classes
.
Packages
In Python, a package is a collection of related modules and subpackages that provide a
specific functionality or service.
Packages are used to organize and structure code, making it easier to reuse and distribute.
Each package contains an __init__.py file, which distinguishes it from a
regular directory and allows Python to recognize it as a package.
mypackage/
│
├── __init__.py
├── module1.py
└── module2.py
main.py
Example pgm
• To write data to a file, you can use the write() method or writelines()
method for multiple lines.
3. Reading from a File
• Reading from a file in Python is a straightforward
process that involves opening the file, reading its
contents, and then closing it.
4. Closing a File
• It is important to close a file after completing operations to free up
system resources.
• Syntax :
Date and Time Operation
Date and time operations in Python are primarily handled using the
datetime module, which provides classes for manipulating dates and
times.
Date Manipulation
Time Manipulation