python os exists directory

没有找到与「python os exists directory」相关的内容

AI 回答 由 glm-4-flash 生成 · 仅供参考,请自行核实
1. 检查目录是否存在:`os.path.exists(directory)`
2. 返回值:True(存在),False(不存在)
3. 示例代码:

import os

directory = "/path/to/directory"
if os.path.exists(directory):
print("目录存在")
else:
print("目录不存在")
没有找到「python os exists directory」相关的内容

建议:检查关键词是否有错别字,或换一个更常见的说法。