简体   繁体   English

如何使用参数运行python脚本?

[英]How to run a python script with arguments?

I downloaded some code from the web which is a python script. 我从网上下载了一些Python脚本代码。 When i run it with my IDE this is the output: 当我用IDE运行它时,输出为:

/usr/local/Cellar/python/2.7.8_1/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/user/PycharmProjects/Pruebas/RBM.py
usage: RBM.py [-h] -d DATASET -t TEST [-s SEARCH]
RBM.py: error: argument -d/--dataset is required

The script has some data in format of a .CSV file with the code, i guess i need to run it in the terminal with some parameters, how can i do this in python?, this is what I had tried: 该脚本具有带有代码的.CSV文件格式的一些数据,我想我需要在终端中使用一些参数来运行它,我该如何在python中执行此操作?

invci-4-244:~ user$ ls
Desktop         Libros          PycharmProjects
Documents       Movies          Torrents
Downloads       Music           Untitled.py
Dropbox         NetBeansProjects    nltk_data
GitHub          Pictures        pycharm-themes
Library         Public          scikit_learn_data
invci-4-244:~ user$ cd pycharm-themes/
invci-4-244:pycharm-themes user$ cd
invci-4-244:~ user$ ls
Desktop         Libros          PycharmProjects
Documents       Movies          Torrents
Downloads       Music           Untitled.py
Dropbox         NetBeansProjects    nltk_data
GitHub          Pictures        pycharm-themes
Library         Public          scikit_learn_data
invci-4-244:~ user$ cd PycharmProjects/
invci-4-244:PycharmProjects user$ ls
Pruebas
invci-4-244:PycharmProjects user$ cd Pruebas/
invci-4-244:Pruebas user$ ls
01_start.py             PruebasVectorizacion.py
02_tuning.py                RBM.py
invci-4-244:Pruebas user$ python ./RBM.py -d//Users/user/Desktop/rbm-logit-mnist/data/digits.csv

The name of the script is RBM.py and the data name is digits.csv, how can i solve this?. 脚本的名称是RBM.py,数据名称是digits.csv,我该如何解决? Thanks! 谢谢!

从用法输出中,我认为语法应该是(请注意-d和csv路径之间的空格):

python ./RBM.py -d /Users/user/Desktop/rbm-logit-mnist/data/digits.csv

如果从终端运行脚本,则可以键入python script.py arguments

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM