Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mkdir() help
#3
(Feb-17-2018, 01:28 PM)Gribouillis Wrote: You can use the __file__ variable. Here is a way to create a directory named 'foo' with the standard pathlib module
from pathlib import Path

p = Path(__file__).resolve().parent/'foo'
if not p.is_dir():
    p.mkdir()

i used this
 def make_file():
    os.getcwd()
    os.chdir('export')
    os.mkdir(str(name.get())) 
it works as intended once now its like this
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\HOME-PC\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
    return self.func(*args)
  File "C:\Users\HOME-PC\Desktop\program_thing\tkinter_program.py", line 20, in make_file
    os.chdir('export')
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'export'
Reply


Messages In This Thread
mkdir() help - by SteampunkMaverick12 - Feb-17-2018, 11:50 AM
RE: mkdir() help - by Gribouillis - Feb-17-2018, 01:28 PM
RE: mkdir() help - by SteampunkMaverick12 - Feb-17-2018, 03:53 PM
RE: mkdir() help - by Gribouillis - Feb-17-2018, 05:30 PM
RE: mkdir() help - by SteampunkMaverick12 - Feb-17-2018, 06:02 PM
RE: mkdir() help - by DeaD_EyE - Feb-17-2018, 06:02 PM
RE: mkdir() help - by SteampunkMaverick12 - Feb-18-2018, 03:20 PM
RE: mkdir() help - by Gribouillis - Feb-17-2018, 06:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  directory not being created after os.mkdir() CAD79 3 536 Mar-16-2024, 04:00 PM
Last Post: deanhystad
  OSERROR When mkdir Oshadha 4 1,944 Jun-29-2022, 08:50 AM
Last Post: DeaD_EyE
  Python Paramiko mkdir command overwriting existing folder. How can i stop that? therenaydin 1 3,352 Aug-02-2020, 11:13 PM
Last Post: therenaydin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020