{article Examples__Python 3.4 }{title} {text}{/article}

Changing working directory in python shell

  1. import os # you can use
  2. os.getcwd # to get the current working directory
  3. os.chdir # change your directory

>>> import os
>>> os.getcwd()
'C:\\Python34'
>>> os.chdir('..')
>>> os.getcwd()
'C:\\'
>>> os.chdir('Python34')
>>> os.getcwd()
'C:\\Python34'
>>>

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
>>> import os
>>> os.getcwd()
'C:\\Python34'
>>> os.chdir('..')
>>> os.getcwd()
'C:\\'
>>> os.chdir('Python34')
>>> os.getcwd()
'C:\\Python34'
>>>
</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}