How to make a folder in python? -mkdir/makedirs doesn't do this right -


i have little problem. i'm kinda new in python need here.

i'm trying make folder should independent on location.

the user can on desktop , make on desktop , if in directiory there , so.

i mean:

os.mkdir('c://program files//....')  

is not good

it's not possible do:

os.mkdir('//just folder') ? 

why have meantion way there?

yes can pass folder name os.mkdir it'll create folder in current working directory. may have change current working directory again , again user or pass whole path os.mkdir if don't want that.

in [13]: import os  in [14]: os.getcwd() out[14]: '/home/monty'  in [15]: os.mkdir("foo")  #creates foo in /home/monty  in [17]: os.chdir("foo") #change current working diirectory `foo`  in [19]: os.getcwd() out[19]: '/home/monty/foo'  in [18]: os.mkdir("bar")  #now `bar` created in `/home/monty/foo` 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -