current position:Home>Python problem Ping
Python problem Ping
2022-07-25 11:18:26【CSDN Q & A】
python By calling ping command , Judge liansuodian LAN in the list ip Whether the address is connected , If it works , Get delay information 、 Packet loss information 、 Average delay and other related return information , And by judging the delay time , The delay time exceeds 10 Second warning , Take out the negative alert information and give it a list value . If it doesn't work, it doesn't work ip Address , Pay an address to a list . every other 10 The automatic cycle is executed every minute .
I wrote it now , If more than one doesn't work , Only the first one can extract ip Address , Then it jumps out of the loop , How can I write it to meet the needs I put forward above . Please point out. thank you , Be deeply grateful
# *--coding=utf-8--*import osimport subprocessimport reimport content as contentfrom pythonping import pingliansuodian = ['193.168.46.254','193.168.46.115','193.168.13.254','193.168.16.254','172.16.10.44']for i in liansuodian: command = os.popen("ping -n 1 " + i) pin = command.read() # print(pin) if " request timeout " in pin: p = i print(p) # print("NO") else: bytime = re.findall(r' Time =(\w)', pin, re.M) print(bytime)
copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/206/202207181917172201.html
The sidebar is recommended
- Xiao Li: "is there a particularly simple case of Python decrypting RSA?" "Really."
- Create a visual GUI interface with Python, and realize various styles of photo processing with one click
- Mecol Studio - the sixth training of Django
- Simple usage of Python @
- Python of__ doc__
- How to use Python to batch import all data in Excel tables into SQL server specified tables?
- Install python3.8 for Ubuntu
- Python string depth summary
- Goodbye datetime! This Python date library is amazing!
- Python image processing -- three operation modes to realize image morphological transformation
guess what you like
About the problem that the front-end video tag video cannot drag the progress bar fast forward (Django)
Sequence data structures commonly used in Python
On the drawing toolkit in Python
Pandas - create data structures and basic attributes, sorting
The use and difference of Python apply (), applymap (), map ()
Pandas - detailed usage of groupby(), append, insert
Python interacts with MySQL
Processes in Python
Threads in Python
Summary of dictionary method of Python I
Random recommended
- Python split() function!
- Python programming problem -- how to find the full arrangement of a group of numbers
- Talk about several input methods of Python!
- Automatic classification of Python files (no longer worry about missing files)
- String (Python)
- 15 useful Python libraries in Data Science
- [untitled] Python -- common code 1 for file processing (make file processing easy!)
- Use MATLAB, C, python to write programs, judge and output all primes between M and N!
- Use Python to draw plant leaves from the perspective of probability!
- Anaconda configuration environment that you must learn to get started with python (with pictures and steps)
- Python inputs a number and finds all its prime factors
- Python calculates the length of the last word of a string separated by spaces. The length of the string is less than 5000
- Python completes n[str] decompression
- Random numbers of Python Programming Problems
- The children of two classes in Python got mixed up when they lined up. Each child knew whether he was in the same class with the previous child, and found out the children in the same class
- Python separates strings by length, and if not enough, 0 is added
- Python converts hexadecimal to hexadecimal, and hexadecimal to hexadecimal.
- Python2 realizes string flipping
- Python2 realizes sentence reverse order
- Python realizes the number, according to the reverse order of the input order, and removes duplicates
- Python consolidated table records: if the first column is the same, the second column is summed
- Python2 string sorting
- Python built-in binary conversion function
- Ubuntu has Python libraries installed and cannot run command not found from the command line
- Python: realize the function of sending file (with complete source code)
- Python realizes the complete visual version of quantile map with Nanhai Jiuduan line (with code and data)
- Time points are classified into different time periods, statistics of data volume in different time periods, Matplotlib drawing ranking, Python
- [Python ticket grabbing artifact] is the train ticket gun ticket software reliable? Actual measurement - the ultimate strategy.
- Python: implement Koch snowflake Koch snowflake algorithm (with complete source code)
- Python drawing multi-dimensional thematic map
- Python: implement Max sub array algorithm (with complete source code)
- Python: implement the minimum cost path algorithm (with complete source code)
- Python: realize the minimum coin change algorithm (with complete source code)
- Python: implement the maximum and continuous subsequence algorithm (with complete source code)
- Python: realize the function of receiving file (with complete source code)
- Python: implement the minimum partition algorithm (with complete source code)
- Python: give an integer n and return the minimum number of steps to 1 algorithm (with complete source code)
- Python: implement Ohms law algorithm (with complete source code)
- Python: implement sum of subset subset summation algorithm (with complete source code)
- Python: implement Mandelbrot Mandelbrot set algorithm (with complete source code)