【发布时间】:2016-08-25 18:20:03
【问题描述】:
我在将路径指定为命令行参数时遇到问题。我在 Windows 上运行。
代码:
import sys
import os
startPath = sys.argv[1]
print startPath
print os.path.dirname(startPath)
命令行参数:
C:\Users\username\Documents\python scripts\New folder
输出:
C:\Users\username\Documents\python scripts\New folder
C:\Users\username\Documents\python scripts
我的问题:
因此,路径的最后一部分 (\New folder) 在目录名称中丢失了。
我做错了什么?
【问题讨论】:
标签: python windows python-2.7 command-line-arguments