Suppose I have the following Fowershell function:
function test {
py
print('hello world')
}
when run, it opens Python in Powershell, but it doesn't execute the code following the 'py' command. how can I make it do that WITHOUT creating a file?
Edit: after quitting python, it outputs Unable to initialize device PRN
. I think it's executing print() after py closes
CodePudding user response:
You can use Python's -c
command line flag:
python -c "print('hello world');print('Second line')"
>> hello world
>> Second line