首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
为什么有的 Python 发行版用 shell 调用 py 文件的时候不能正确传递参数呢?
ljq29
·
2019-05-11 20:41:49 +08:00
· 1868 次点击
这是一个创建于 2153 天前的主题,其中的信息可能已经有所发展或是发生改变。
RTRT,楼主安装了 anaconda 的 python,现在用带参数的命令调用 py 文件,执行的时候不能正确获取参数。
程序编写没有问题,因为 py 文件用 pyinstaller 转换成 exe 之后可以正常读取到参数。
参数
Python
调用
文件
8 条回复
•
2019-05-11 21:48:02 +08:00
1
ipwx
2019-05-11 21:17:49 +08:00
1、你是什么系统。
2、你调用 py 文件的命令行是什么?
一个标准的调用方法(最不容易出错的形式)是 python
aaa.py
参数...
2
ljq29
OP
2019-05-11 21:19:17 +08:00
@
ipwx
Windows 系统,命令行类似这样
main.py
upload localhost matlab matlab matlab_folder a.txt
3
ipwx
2019-05-11 21:20:29 +08:00
还是上面的论点,先试试 python
main.py
upload localhost matlob matlob matlob_folder a.txt
windows 系统的文件关联很搞,也许你的 .py 在注册表里面关联的执行程序 template 有问题。
4
ljq29
OP
2019-05-11 21:23:48 +08:00
@
ipwx
这样就可以了,这是为什么呢?
5
ljq29
OP
2019-05-11 21:24:11 +08:00
@
ipwx
另外问一下,如果参数中间有空格怎么解决呢?
6
aquariumm
2019-05-11 21:26:29 +08:00 via Android
@
ljq29
双引号
7
seers
2019-05-11 21:28:47 +08:00
有点像环境变量问题
8
ljq29
OP
2019-05-11 21:48:02 +08:00
@
seers
之前的默认 python 版本是 Lyx 自带的,但是版本有点低。我重装了一遍 anaconda,就成了这个样子。
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
1023 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 24ms ·
UTC 22:21
·
PVG 06:21
·
LAX 15:21
·
JFK 18:21
Developed with
CodeLauncher
♥ Do have faith in what you're doing.