0

If a user wants to create, for example, a project in PyCharm, you would first pick a folder using File Explorer and then the project would be created in that folder.

How can I do that using Python?

I know there is a module called subprocesswhich can open File Explorer using this command subprocess.Popen("explorer") but that's about all I know.

How can I make the user choose a folder a file will be stored in and then create a file in that location?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241

1 Answers1

0

you can use this:

    from tkinter import filedialog
    folder = filedialog.askdirectory(initialdir=os.path.expanduser('~'))

this =os.path.expanduser('~') will open the explorer in the HOME folder

LinPy
  • 16,987
  • 4
  • 43
  • 57