python determine whether a file exists

Determine whether a file exists os.path.exists (file_path)

To delete a file: os.remove (file_path)

 

 

import os

file_path="d:/mk.txt"

if os.path.exists(file_path)==True:
    os.remove(file_path)

 

Guess you like

Origin blog.csdn.net/qq_35577990/article/details/89813523