import os import os if os.path.isdir("path"): print("他是文件夹") if os.path.isfile("path"): print("他是文件")