0% found this document useful (1 vote)
74 views

Python Quick Reference

This document provides instructions for determining the current working directory and changing directories in Python. It shows how to use the os.getcwd() function to print the current directory and os.chdir() to change to a new directory like "codechef". It also demonstrates how to open a file, read its contents, and print the file contents.

Uploaded by

machnik1486624
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
74 views

Python Quick Reference

This document provides instructions for determining the current working directory and changing directories in Python. It shows how to use the os.getcwd() function to print the current directory and os.chdir() to change to a new directory like "codechef". It also demonstrates how to open a file, read its contents, and print the file contents.

Uploaded by

machnik1486624
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

To know the directory in which I am working in idle

>>> import os
>>> os.getcwd()
'C:\\Program Files\\Python33'

Change directory
os.chdir("codechef") #change current working directory

Files:

txt = open(filename)
txt.read()
Print(txt.read()) – Print file contents

You might also like