简体   繁体   中英

Python Command Output Terminal

This question is most likely on here somewhere, and anyone who can redirect me, that would be great.

But I can't find it - most likely not sure which appropriate key terms to use as everything gives me the python command line interpreter.

But I simply want to be able to use the output from a python as the input to another program from the command line. For example:

./program `python print 'A' * 100`

However, I get an error of:

python: can't open file 'print': [Errno 2] No such file or directory

What is the proper way to do this?

the python executable with no switches expects no arguments(for an interactive shell) or a *.py file to run

you can use the -c switch to pass in code

./program `python -c "print 'A' * 100"`
python -c "print 'A' * 10" | ./program

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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