首页 > 解决方案 > Strange Google Colab ping result

问题描述

When I try to use ping in colab I get:

!ping binance.com
/bin/bash: ping: command not found

The quick reference guide is not showing ping:

%quickref

But using os library seems to execute the ping command:

import os
os.system("ping binance.com")
32512

What is the meaning of the result? (32512)

标签: pythongoogle-colaboratory

解决方案


我认为目前,除非您为 pro 付费,否则在 google colab 中没有其他使用终端的方法。ping 中的 32512 表示密钥已过期。

 import os
 hostname = "binance.com" 
 response = os.system("ping -c 1 " + hostname)
 
 if response == 0:
  print(hostname, 'Connected')
else:
  print(hostname, 'Connect Fail')

你可以试试这个代码,应该会给你一个更清晰的结果,即“连接失败”过去,你可以使用 Teleconsole,但它自 2021 年 9 月 4 日起被关闭


推荐阅读