【发布时间】:2025-12-21 18:50:15
【问题描述】:
我得到了如何将文件作为参数传递的答案How to access variables from file passed through command line
但我是分开问的,因为不想混合两个。
我能够以__import__(sys.argv[1]) 的形式访问传递文件中的变量并调用python test.py config。但是我可以通过给出 pythonpath 来调用 config.py 文件吗? e/g/python test.py ~/Desktop/config或PYTHONPATH='~/Desktop/' python test.py config?因为如果我这样做,我会得到no module error。
【问题讨论】:
标签: python python-2.7 arguments parameter-passing command-line-arguments