Discuss / Python / Mac下给以权限,终端下执行./hello.py时,无法执行,总是vi打开hello.py

Mac下给以权限,终端下执行./hello.py时,无法执行,总是vi打开hello.py

Topic source

asistert

#1 Created at ... [Delete] [Delete and Lock User]

问题如上

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

print('Hello, world')

终端下切换到文件目录

chmod a+x hello.py

执行

./hello.py

之后终端中vim自动加载了hello.py 相当诡异啊

asistert

#2 Created at ... [Delete] [Delete and Lock User]

问题解决,原来在

.zshrc

中添加了一句别名导致终端下只要是python文件就默认被vi打开

alias -s py=vi

  • 1

Reply