【发布时间】:2018-08-10 14:31:41
【问题描述】:
我是 python 初学者。试图传递一些命令行参数。 我使用了以下代码。但是出现错误... transaction_file = argv[1] IndexError: 列表索引超出范围。
import itertools
import re
from sys import argv
print ('Computing frequent item sets.')
transaction_file = argv[1]
parameter_file = argv[2]
output_file = argv[3]
非常感谢任何帮助。谢谢......
【问题讨论】:
-
在你的cmd中,运行的命令应该是:python filename.py parameters
-
看看这篇关于 Python 中 CLI 参数的教程:tutorialspoint.com/python/python_command_line_arguments.htm
-
你应该从终端运行
-
你是如何执行你的python文件的?
标签: python command-line-arguments