且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何接受命令行参数?

更新时间:2023-08-25 23:18:04

此代码在Python 2.0中。


/ usr / bin / python hello.py 1 2 4 6 9


我有几个我一直在分发的例子是我的dex跟踪器项目中的tracker8.py(底部是url)。我做的是使用主要功能。您正在编写的代码看起来对我正在做的事情非常有用,并且可能允许从文件到您正在调零的列中的一系列数字可能对我的项目有很好的贡献:) ... http ://www.stormpages.com/edexter/csound.html

Right now, I have this python script that lets me choose which column of a text file that I can zero out. Them column nubmer is stored as the variable ''elem''. I also was given a sample of taking in command line arguements. I was wondering if anyone could help me intergrate this into the code so that from the command line I can input a number and have the script zero out the column.

beginning text file:
#Number of Bits
12
#Data
0 0 0 0 0 0 0 0 0 0 0 0
12 5 3 4 6 4 5 4 7 5 5 10
24 9 7 7 13 7 9 9 14 10 10 20

text file after script has been run:
#Number of Bits
12
#Data
0 0 0 0 0 0 0 0 0 0 0 0
0 5 3 4 6 4 5 4 7 5 5 10
0 9 7 7 13 7 9 9 14 10 10 20
and this is what it does:

Expand|Select|Wrap|Line Numbers

This code is in Python 2.0.


/usr/bin/python hello.py 1 2 4 6 9


I have a couple of examples that I have been distributing one is in tracker8.py available in my dex tracker project (url at bottom). What I did was use a main function. The code you are writing looks like it would be usefull for what I am doing and maybe something that would allow a series of numbers from a file into the column you are zeroing out might be a good contribution to my project :) ... http://www.stormpages.com/edexter/csound.html


上一篇 : :命令行Python应用程序中的多行用户输入下一篇 : 哪个更快:多个单插入还是一个多行插入?

相关阅读

推荐文章