Python Forum
[Tkinter] remove file from current project
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] remove file from current project
#2
test if the file exists

this works

from os import path, remove

def file_remover(file):
    if path.exists(file):
        remove(file)
        print('file removed')
    else:
        print('file does not exist')

file_remover('test.pdf')
Output:
file removed
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
remove file from current project - by rwahdan - Jul-24-2021, 03:02 PM
RE: remove file from current project - by menator01 - Jul-25-2021, 06:14 AM
RE: remove file from current project - by Larz60+ - Jul-25-2021, 09:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Unable to get current contents of the entry field where the content is the file path pmpinaki 1 2,270 Apr-18-2020, 06:45 PM
Last Post: deanhystad
  python file(.py) not working with my tkinter project DeanAseraf1 9 7,332 Mar-22-2020, 10:58 PM
Last Post: ifigazsi
  Problem In calling a Function from another python file of project vinod2810 7 5,464 Oct-05-2019, 01:09 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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