第一种:
#!/usr/bin/env python
import osip=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的效果那样~
转载于:https://blog.51cto.com/josion/1244138