源码如下:

import os
import time


def open_cmd(command):
    fp = os.popen(command)
    return fp


def export_dmp(drive_letter, dm_bin_path, sysdba, sysdba_password, host, port, dmp_dir, owner_and_schema):
    t = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
    file_name = t + '-' + owner_and_schema + '-exp'
    commands_dm = rf'commands'
    try:
        open_cmd(commands_dm)  # 源码中此处执行完后会生成一个dmp文件
    except Exception as err:
        print(err)
    dmp_file_path = os.path.join(dmp_dir, f'{file_name}.dmp')  # eg: D:/test/dm_sql/20220526112545-LSZ_INSIDE-exp.dmp
    # dmp_file_path = dmp_dir + file_name + '.dmp'
    # if os.path.exists(os.path.realpath(dmp_file_path)):       # false
    # if os.path.exists(dmp_file_path):                         # false
    return dmp_file_path, os.path.realpath(dmp_file_path)

如上所述, 判断始终是 false, 文件是实际存在的, 而且我把路径 D:/test/dm_sql/20220526112545-LSZ_INSIDE-exp.dmp 字符串直接拿去判断又能返回 True, 有点迷, 希望大佬们能帮我看看


↙↙↙阅读原文可查看相关链接,并与作者交流