加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vim – 如何设置Syntastic作为python3检查器而不是python2

发布时间:2020-12-16 01:18:15 所属栏目:安全 来源:网络整理
导读:在MacVim中,我将以下代码保存为test.py print "Hello world! python2" ,这显然是python3的错误,但是 运行后:w保存文件,没有错误信息, 以下是?/ .vimrc的一部分,它是关于Syntastic的: " Syntastic "" Recommended settings set statusline+=%#warningmsg# s
在MacVim中,我将以下代码保存为test.py
print "Hello world! python2"

,这显然是python3的错误,但是
运行后:w保存文件,没有错误信息,
以下是?/ .vimrc的一部分,它是关于Syntastic的:

" Syntastic                                                                     
"" Recommended settings                                                         
set statusline+=%#warningmsg#                                                   
set statusline+=%{SyntasticStatuslineFlag()}                                    
set statusline+=%*                                                              
let g:syntastic_always_populate_loc_list = 1                                    
let g:syntastic_auto_loc_list = 1                                               
let g:syntastic_check_on_open = 1                                               

"" Display checker-name for that error-message                                  
let g:syntastic_aggregate_errors = 1        

"" I use the brew to install flake8                                             
let g:syntastic_python_checkers=['flake8','python3']

如何在终端中运行test.py时使Syntastic检测到这种类型的错误:

NingGW:Desktop ninggw$python3 test.py
  File "test.py",line 1
    print "Hello world! python2"
                               ^
SyntaxError: Missing parentheses in call to 'print'

以下是:SyntasticInfo说:

Syntastic version: 3.8.0-10 (Vim 800,Darwin,GUI)
Info for filetype: python
Global mode: active
Filetype python is active
The current file will be checked automatically
Available checkers: flake8 python
Currently enabled checker: flake8
Press ENTER or type command to continue
flake8是一个Python包.它使用Python的内置工具来解析代码 so it accepts syntax for the Python version that it belongs to.

如何为python3安装安装它取决于安装本身的安装方式 – unless you’re fine with using pip.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读