Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 使用python2.7和python3.x的Vim源代码编译选项_Python 2.7_Python 3.x_Vim - Fatal编程技术网

Python 2.7 使用python2.7和python3.x的Vim源代码编译选项

Python 2.7 使用python2.7和python3.x的Vim源代码编译选项,python-2.7,python-3.x,vim,Python 2.7,Python 3.x,Vim,我想使用vim编写Python2/3代码,我想知道如何在编辑器中编译和运行?有人有什么好的建议吗,谢谢?可以使用r运行代码。以下是一个例子: 如果使用vim编写python2和python3,可能应该使用+python2编译vim,使用+python3编译另一个vim(然后使用第一个编写python2代码,第二个编写python3代码) 因为Pymode和其他python插件需要+python2/3,但问题是vim不能同时使用它们进行编译 可以使用r运行代码。以下是一个例子: 如果使用vim

我想使用vim编写Python2/3代码,我想知道如何在编辑器中编译和运行?有人有什么好的建议吗,谢谢?

可以使用
r
运行代码。以下是一个例子:

如果使用vim编写python2和python3,可能应该使用
+python2
编译vim,使用
+python3
编译另一个vim(然后使用第一个编写python2代码,第二个编写python3代码)

因为Pymode和其他python插件需要
+python2/3
,但问题是vim不能同时使用它们进行编译

可以使用
r
运行代码。以下是一个例子:

如果使用vim编写python2和python3,可能应该使用
+python2
编译vim,使用
+python3
编译另一个vim(然后使用第一个编写python2代码,第二个编写python3代码)


因为Pymode和其他python插件需要
+python2/3
,但问题是vim不能同时使用它们进行编译

我使用一个简单的脚本来运行python程序。它所需要的只是在机器上安装python。它所做的是运行程序并在Vim的覆盖框中显示其输出。问题是:如果你的程序是交互式的,它将无法工作。它所做的一切都是在程序完成后显示其输出

我所做的是:

command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
    let isfirst = 1
    let words = []
    for word in split(a:cmdline)
        if isfirst
            let isfirst = 0  " don't change first word (shell command)
        else
            if word[0] =~ '\v[%#<]'
                let word = expand(word)
            endif
            let word = shellescape(word, 1)
        endif
        call add(words, word)
    endfor
    let expanded_cmdline = join(words)
    botright new
    setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
    "call setline(1, 'You entered:  ' . a:cmdline)
    call setline(1, 'CMD:  ' . expanded_cmdline)
    call append(line('$'), substitute(getline(2), '.', '=', 'g'))
    silent execute '$read !'. expanded_cmdline
    1
endfunction
/ftplugin/python.vim


我所要做的就是使用
,r
(我的
),它运行当前打开的python文件并显示其输出

我使用一个简单的脚本来运行python程序。它所需要的只是在机器上安装python。它所做的是运行程序并在Vim的覆盖框中显示其输出。问题是:如果你的程序是交互式的,它将无法工作。它所做的一切都是在程序完成后显示其输出

我所做的是:

command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
function! s:RunShellCommand(cmdline)
    let isfirst = 1
    let words = []
    for word in split(a:cmdline)
        if isfirst
            let isfirst = 0  " don't change first word (shell command)
        else
            if word[0] =~ '\v[%#<]'
                let word = expand(word)
            endif
            let word = shellescape(word, 1)
        endif
        call add(words, word)
    endfor
    let expanded_cmdline = join(words)
    botright new
    setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
    "call setline(1, 'You entered:  ' . a:cmdline)
    call setline(1, 'CMD:  ' . expanded_cmdline)
    call append(line('$'), substitute(getline(2), '.', '=', 'g'))
    silent execute '$read !'. expanded_cmdline
    1
endfunction
/ftplugin/python.vim

我所要做的就是使用
,r
(我的
),它运行当前打开的python文件并显示其输出