Home > other >  Python experts to help them, and want to write a simple ping command, but always error when cycle
Python experts to help them, and want to write a simple ping command, but always error when cycle

Time:01-07

Write a LAN ping command,
The import OS
I=1
I & lt; 255
Print (OS) system (' ping - n 1 192.168.1. '+ STR (I)))
I=I + 1


I=I + 1
^
System of execution results suggest: unexpected imdent, how to join the cycle and save the corresponding results, thank you!

CodePudding user response:

According to your code, like below:

 I=1While I & lt; 255: 
Print (OS) system (' ping - n 1 192.168.1. '+ STR (I)))
I=I + 1

But the meaning of this code is, ping 192.168.1.1 to 192.168.1.254, a total of 254 IP addresses, and that it will open 254 CMD window,,,,
This is the result you want?

CodePudding user response:

Indentation is not correct

CodePudding user response:


Thank you very much!
  • Related