Linux系统下获取公网ip

2017.7.2更新

命令行方式:

curl http://ifconfig.me/ip   (较慢)

curl ip.cip.cc

或者 curl cip.cc(详细)

 

树莓派Python使用:

import os

ipResult = os.popen('curl ip.cip.cc').read()    #得到字符串 ip + /n,需要去掉回车符

ip = ipResult.replace('\n','')

print(ip)

 

posted @ 2017-07-02 13:42  Iceyes  阅读(315)  评论(0)    收藏  举报