28.10.2021 Views

Python Tutorial ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Locating Modules: .................................................................................. 214

The PYTHONPATH Variable: ................................................................ 214

Namespaces and Scoping: .................................................................... 215

The dir( ) Function: ................................................................................. 215

The globals() and locals() Functions: ..................................................... 216

The reload() Function: ............................................................................ 216

Packages in Python: .............................................................................. 216

Python Files I/O ..................................................................... 218

Printing to the Screen: ............................................................................ 218

Reading Keyboard Input: ....................................................................... 218

The raw_input Function: ......................................................................... 218

The input Function: ................................................................................ 219

Opening and Closing Files: .................................................................... 219

The open Function: ................................................................................ 219

SYNTAX: .............................................................................................. 219

The file object attributes: ........................................................................ 220

EXAMPLE: ............................................................................................. 220

The close() Method: ............................................................................... 221

SYNTAX: ................................................................................................ 221

EXAMPLE: ............................................................................................. 221

Reading and Writing Files: ..................................................................... 221

The write() Method: ................................................................................ 221

SYNTAX: ................................................................................................ 221

EXAMPLE: ............................................................................................. 221

The read() Method: ................................................................................ 222

SYNTAX: ................................................................................................ 222

EXAMPLE: ............................................................................................. 222

File Positions: ......................................................................................... 222

EXAMPLE: ............................................................................................. 222

Renaming and Deleting Files: ................................................................ 223

The rename() Method: ........................................................................... 223

SYNTAX: ................................................................................................ 223

EXAMPLE: ............................................................................................. 223

The remove() Method: ............................................................................ 223

SYNTAX: ................................................................................................ 223

EXAMPLE: ............................................................................................. 224

Directories in Python: ............................................................................. 224

The mkdir() Method: ............................................................................... 224

TUTORIALS POINT

Simply Easy Learning

SYNTAX: .............................................................................................. 224

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!