1、执行命令“touch file.py”创建python文件;

2、执行命令“vim file.py”编辑python文件;

3、输入如下代码:
#/usr/bin/python3.5
import os
def search(path):
if os.listdir(path):#判断文件夹是否为空
print( os.listdir(path) )
else:
print('Sorry,This is an empty folder.')
path = input('Please input the file path:')
search(str(path))

4、执行命令“:wq”保存退出当前文件;

5、执行命令“python3 file.py”运行python程序;

6、输入有文件的目录“/tmp”,返回文件和子文件夹列表;

7、输入没有任何文件的目录“/home”,返回“Sorry,This is an empty folder.”(对不起,这是一个空文件夹)。至此用python判断空文件夹的程序已经成功实现。
