create a directory in python
assuming you're running some *nix (including mac os x), here's how to create a directory from within a python script. note that we need to check if the directory exists before creating a directory (if you try and overwrite a directory, python will throw an error).
here goes:
import os;
...
dirname = "my_dir_name"
if not os.path.isdir("./" + dirname + "/"):
os.mkdir("./" + dirname + "/")
note that the last line needs to be indented (silly blogger won't let me indent that line!)
0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home