第一种

import commands
cmd = "ifconfig br0 | grep 'inet addr' | sed 's/^.*addr://g' |sed 's/ Bcast:.*$//g'"
(status, ip) = commands.getstatusoutput(cmd)

 

 

第二种

shell下的一句话脚本,在命令行执行以下语句

python -c "import socket;print([(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1])"

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-14
  • 2021-12-31
  • 2021-11-02
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案