D
D
Doombreaker2020-12-31 13:06:35
Python
Doombreaker, 2020-12-31 13:06:35

How to open python file via powershell?

I am learning python from a book, it says to open a python file through PowerShell, while setting the value of argv, that is, like this:
python file.py first 2nd 3rd
After that, everything should work, but nothing happens to me, but just a new line appears.
The code to be opened is:

from sys import argv
script, first, second, third = argv
print('Этот сценарий называется',script)
print('Моя первая переменная',first)
print('Моя вторая переменная',second)
print('Моя третья переменная',third)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex F, 2020-12-31
@delvin-fil

Because you need to enter four arguments.
python file.py example 1argument 2argument 3argument
Just copy this and paste it on the command line. You will see the following:
> example
> 1argument
> 2argument
> 3argument

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question