大佬教程收集整理的这篇文章主要介绍了尝试从 Python3 全局类中获取文件名或目录,然后使用 bash 脚本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我不断收到 sHell 错误: python3: 无法打开文件 'path/to/service.py': [Errno 2] 没有那个文件或目录
**globals.py** #contains a Dictionary: serviCE_MAP = { 'test': '~/path/to/service.py','test2': '$HOME/path/to/service.py','test3': '/full/path/to/service.py',}
@H_419_13@我已经尝试了上述所有形式的服务路径。检索方法为:
**launch.sh** function get_service() { python3 -c "import common.globals as gbl; print(gbl.serviCE_MAP['$1'])" }
@H_419_13@然后调用:
**launch.sh** service=$(get_service "test") # get service "test" echo $service #Output: is what it should be... "path/to/service.py" # but when I Now do: python3 $service #or python3 "$service" Output is always: python3: can't open file '/path/to/service.py': [Errno 2] No such file or directory
@H_419_13@我在这里做错了什么?
解决方法
以上是大佬教程为你收集整理的尝试从 Python3 全局类中获取文件名或目录,然后使用 bash 脚本全部内容,希望文章能够帮你解决尝试从 Python3 全局类中获取文件名或目录,然后使用 bash 脚本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。