سؤال

I want to write a python script that requires one argument as input, followed by the data as stdin. So at the end I want to be able to run the program as follows:

cat mydata | ./mycode.py -inx 2:5 -

or without dash:

cat mydata | ./mycode.py -inx 2:5

The input argument specifies which columns should be considered in the code.

I would appreciate any suggestions

هل كانت مفيدة؟

المحلول

sys.stdin gives you a stream object from standard input. You can then just use it as a stream.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top