windows powershell/linux run manage.py(Django) without typing python ahead在命令行中将python(.py)文件作为脚本运行
powershell run manage.py without type python ahead
preface
这里(下方的讨论)以django项目中的
manage.py
脚本文件为例
for windows
设置打开.py文件的默认行为
- (选择python解释器打开)
- 如果是GUI编辑器,就达不到效果(当你用manage.py打头,powershell会尝试启动编辑器打开
manage.py
,这不是我们想要的)
效果
我在powershell下跑一段测试
省略掉后缀py
配置PathExt环境变量
将
;py
加入到该变量取值序列中
- 这将使得系统能够在你不给出后缀的情况下尝试判断环境变量PathExt中的后缀取值序列
for linux
- 在linux中想要省略掉
python
这个单词很简单,只需要配置别名即可
譬如:alias manage='python manage.py'