在阅读最近在 SO 上回答的问题后,我想要一种快速简单的方法来检查我的 IP 地址。为了将来引用,是否有办法使以下别名起作用?
alias myip='python -c "from urllib import urlopen; print urlopen("http://whatismyip.appjet.net").read()[:-1]"'
最佳答案
alias myip="python -c 'from urllib import urlopen; print urlopen(\"http://whatismyip.appjet.net\").read()[:-1]'"
您需要在别名内使用单引号以阻止 bash 尝试解释其中的部分代码。在处理别名本身时,双引号上的转义符会被删除。
关于python - 如何使此 python 命令行成为 bash 中的别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/617952/