判断是否是一个目录

[root@zabbix-server python3]# cat dir.py
1 #!/usr/bin/python3
2 # -*- coding: utf-8 -*-
3 import os
4 dir = "/home/o2ouser/python3"
5 if os.path.isdir(dir):
6    print('%s is a dir' % dir)
7 else:
8    print('%s is not a dir' % dir)

 

posted @ 2019-08-26 15:48  菩提花开  阅读(221)  评论(0编辑  收藏  举报