是否可以使用"py"而不是"python"在Linux的命令行中? [英] Is it possible to use "py" instead of "python" at the command line in Linux?

查看:104
本文介绍了是否可以使用"py"而不是"python"在Linux的命令行中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否认为在Ubuntu中,不是每次我想运行脚本时都键入python3 test.py,而是使用类似这样的速记形式:py test.py?换句话说,我要为python3编写一个简写命令,该命令应如下所示:py.我可以这样做吗?

Do you think it's possible in Ubuntu instead of typing python3 test.py every time I want to run a script, to use a shorthand equivalent such like this: py test.py? In other words, what I want is to make a shorthand command for python3 that should look like this: py. Can I do that?

推荐答案

好的.您可以使用bash alias命令执行以下操作:

Sure. You can use the bash alias command to do something like this:

alias py=python3

将其放置在类似于.bashrc和IIRC的位置,将为每个(交互式)会话进行设置.

Put it somewhere like .bashrc and IIRC it will be set up for each (interactive) session.

这篇关于是否可以使用"py"而不是"python"在Linux的命令行中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆