def delete_empty_dir(directory):
    """
    删除空目录

    :param directory: 目录路径
    """
    if os.path.exists(directory):
        if os.path.isdir(directory):
            for d in os.listdir(directory):
                path = os.path.join(directory, d)
                if os.path.isdir(path):
                    delete_empty_dir(path)

        if not os.listdir(directory):
            os.rmdir(directory)
            print("Remove the empty directory: " + directory)
    else:
        print("The directory is not exist!")
def delete_empty_dir(directory):
    """
    删除空目录

    :param directory: 目录路径
    """
    if os.path.exists(directory):
        if os.path.isdir(directory):
            for d in os.listdir(directory):
                path = os.path.join(directory, d)
                if os.path.isdir(path):
                    delete_empty_dir(path)

        if not os.listdir(directory):
            os.rmdir(directory)
            print("Remove the empty directory: " + directory)
    else:
        print("The directory is not exist!")
def delete_empty_dir ( directory ) : if os . path . exists ( directory ) : if os . path . isdir ( directory ) : for d in os . listdir ( directory ) : path = os . path . join ( directory , d ) if os . path . isdir ( path ) : delete_empty_dir ( path ) if not os . listdir ( directory ) : os . rmdir ( directory ) print ( "Remove the empty directory: " + directory ) else : print ( "The directory is not exist!" )
删除空目录

    :param directory: 目录路径
删除空目录