嗨,我正在尝试找到一种方法来使用 python 计算特定 IP 的往返时间。我所能找到的只是使用一个网址,但这不是我希望它工作的方式,到目前为止没有任何信息有用
我只找到了这段代码:
import time
import requests
# Function to calculate the RTT
def RTT(url):
# time when the signal is sent
t1 = time.time()
r = requests.get(url)
# time when acknowledgement of signal
# is received
t2 = time.time()
# total time taken
tim = str(t2-t1)
print("Time in seconds :" + tim)
# driver program
# url address
url = "http://www.google.com"
RTT(url)
谁能告诉我如何调整此代码以获取 IP 地址而不是 URL?谢谢