V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
woshichuanqilz
V2EX  ›  Vim

vim Python 脚本如何实现对自定义 Python 文件的引入?

  •  
  •   woshichuanqilz · Oct 5, 2022 · 1791 views
    This topic created in 1307 days ago, the information mentioned may be changed or developed.
    function! Test()
    py << EOF
    import twUtils
    
    EOF
    endfunction
    

    这个是我的 vim script. 我有一个 python 文件 twUtils.py 在同一个目录下面,里面有一个函数,我想在 vim 里面调用这个函数,但是我不知道怎么调用,我试了很多方法都不行,我想知道怎么调用这个函数,谢谢。

    2 replies    2022-10-05 22:20:19 +08:00
    amlee
        1
    amlee  
       Oct 5, 2022
    你这跟 vim 没关系啊,去看看 python 导包语法吧。

    简单说:你在 twUtils.py 下写一个 test.py 文件,然后 test.py 里面写入

    from twUtils import xxx
    woshichuanqilz
        2
    woshichuanqilz  
    OP
       Oct 5, 2022
    @amlee 如果外面写一个其他的调用 twUtils.py 的脚本是正常的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   856 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:11 · PVG 03:11 · LAX 12:11 · JFK 15:11
    ♥ Do have faith in what you're doing.