【问题标题】:python .bash_profile aliaspython .bash_profile 别名
【发布时间】:2013-02-22 11:01:42
【问题描述】:

我正在尝试从别名 (macosx) 执行 python 文件。

有可能吗?

alias execute ='python path/file.py'

我正在尝试这样,但不起作用,有什么建议吗?

谢谢

【问题讨论】:

  • 如果你指定了file.py的相对路径,它不会从另一个目录去。
  • “不起作用”总是对所发生的事情的错误描述。

标签: python macos alias .bash-profile


【解决方案1】:

删除=之前的空格,它应该可以工作:

$ cat /tmp/x.py 
print 'hello, world!'

$ alias execute='python /tmp/x.py'
$ execute
hello, world!

另请注意,我使用的是绝对路径 (/tmp)。使用相对路径会使命令在某些目录中有效,但在其他目录中无效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    • 2019-01-28
    • 1970-01-01
    • 2016-08-14
    • 2017-10-24
    • 2015-04-02
    • 2010-10-28
    相关资源
    最近更新 更多