求python中的os.path.dirname file 具体应用实例(pythonfile文件使用教程)

求python中的os.path.dirname file 具体应用实例(pythonfile文件使用教程)

首页维修大全综合更新时间:2024-04-06 14:04:53

求python中的os.path.dirname file 具体应用实例

(1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如: python d:/pythonSrc/test/test.py 那么将输出 d:/pythonSrc/test (2).当"print os.path.dirname(__file__)"所在脚本是以相对路径被运行的, 那么将输出空目录,比如: python test.py 那么将输出空字符串

大家还看了
也许喜欢
更多栏目

© 2021 3dmxku.com,All Rights Reserved.