8516830 发表于 2018-8-9 10:25:43

python实现获取服务器IP地址

  第一种:
  #!/usr/bin/env python
importos  ip=os.popen("ifconfig eth0 | awk -F [:' ']+ 'NR==2{print $4}'")
  print ip.readline()
  第二种:
  >>> os.system("ifconfig eth0 | awk -F [:' ']+ 'NR==2{print $4}'")
  想问问:python里有过滤字符的命令吗,就像shell中的grep的效果那样~
页: [1]
查看完整版本: python实现获取服务器IP地址