Creating a folder in Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Creating a folder in Python

This is how to create folder named “tmp” in Ruby: tmpDir = File.dirname(items[0]) + "/tmp/" if ! File.directory?(tmpDir) # If directory does not exist! Create it! FileUtils.mkdir_p(tmpDir) end How about in Python? Thank you so much

29th Oct 2018, 6:42 AM
Vosen Chen
Vosen Chen - avatar
3 Answers
+ 4
If you want to create folder or working with window system then os module is use for it. here it is tutorial of os module. https://youtu.be/tJxcKyFMTGo
29th Oct 2018, 7:19 AM
Maninder $ingh
Maninder $ingh - avatar
+ 7
import os path = "relative/path" if not os.path.isdir(path): os.mkdir(path)
29th Oct 2018, 8:13 AM
Mert Yazıcı
Mert Yazıcı - avatar
+ 2
thank you Maninder Singh ,Mert Yazıcı , it helps me a lot :)
29th Oct 2018, 8:23 AM
Vosen Chen
Vosen Chen - avatar