check file Existing with Python Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gabriel9999
    New Member
    • Jul 2019
    • 15

    check file Existing with Python Script

    Are there any way to check the file existence in Python script.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Import the os module and use the os.path.isfile( path) function

    Comment

    • edizgeorgi
      New Member
      • Oct 2019
      • 8

      #3
      Python provides exists() function which can be used like below.
      Code:
      import os.path  
      
      if(os.path.exists("/etc/passwd")):  
      
         print("/etc/passwd exists")
      Last edited by Rabbit; Jun 11 '20, 07:20 PM. Reason: Removed external link

      Comment

      Working...