Skip to content
  • View menu
  • View sidebar

bioinfo core

Index & solution of bioInfo utilities

  • Home
  • All entries
  • Blogs
  • Contact
  • About

Categories

  • Between languages (7)
  • Blogs (8)
  • Python (35)
  • R (1)
  • Unix (37)

Tags

bedfile Blogs conda Excel html numpy Pandas Python R slurm Unix
09/10/202002/01/2023 by bioinfocore

Python check if a file or directory exists

  • Between languages, Python, Unix
  • Python, Unix
import os.path

# Check if a file exist, return True/False
os.path.exists("test.txt")

# Check if a directory exist, return True/False, for >= python3.4
import pathlib
pathlib.Path("test").exists()

Source:
https://www.guru99.com/python-check-if-file-exists.html

Post navigation

← Previous Post Python return os.system and subprocess output as a string
Next Post → Python remove elements from a list
Copyright 2024 | by bioinfocore