Created
January 30, 2017 15:24
-
-
Save guerbai/3247ac1f433aa3e869294761f9eda046 to your computer and use it in GitHub Desktop.
Python获得调用系统命令在命令行的输出.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commands | |
def get_location(ip): | |
cmd = "curl http://www.ip.cn/{}".format(ip) | |
result = commands.getoutput(cmd) | |
location = result.split("\n")[-1].split(":")[-1] | |
return location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment