質問

While doing this it gives me an error:

Traceback (most recent call last):
     File "C:\Users\ibrahim\Desktop\app.py", line 23, in <module>
       a=input("enter the ipaddress")
     File "<string>", line 1
       192.168.1.1
               ^
   SyntaxError: invalid syntax

Here's my code:

import os
a=input("enter the ipaddress")
os.system('a')


it does not work help me out !!!
役に立ちましたか?

解決

You are passing the string 'a' not the variable a, take the quotation marks off:

import os
a=input("enter the ipaddress")
os.system(a)

他のヒント

I would suggest to use hostname instead of a, because as you will run some commands after ssh to some device, the input should get assigned as hostname - ssh.connect(hostname, port=22, username=x, password=y). So the suggested code is -

import os
hostname=input("enter the ipaddress")
os.system(hostname)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top