Closed Dekay999 closed 3 years ago
:AsyncRun -mode=term -pos=external -raw python %
Hi skywind, by using -pos=external
, I got this:
still, chinese character can't be displayed properly.
what is your file encoding ??
utf-8
add a header to your python source:
# -*- coding: utf-8 -*-
still the same output... By the way, I was using MSYS2 in windows10 system.
And if I run python in the Terminal, everything is OK: So, this is really weird.
你别告诉我你是在用 windows 下的 gvim 操作 msys
哈哈, 原来是中国人, 我是在windows下装了MYSYS2, 在MSYS2里面用pacman装了vim
我是用的MSYS2终端, 那可能是MSYS2本身的编码问题, 我再研究研究, 多谢了
不知道了,有点诡异。
刚才的办法还有问题, 会把.py文件中的中文变成乱码(因为MSYS2和.py编码文件不一致). 下面的办法终于可以完美解决了. 首先明确根本原因是windows终端使用的是gbk
编码, 而python使用utf-8编码, 所以解决方案如下: 把MSYS2的编码设置成utf-8来正常显示代码中的中文, 然后编写/bin/win文件:
#!/bin/bash
$@ |iconv -f gbk -t utf-8
然后使用asyncrun时在python前面加上win:
:AsyncRun -mode=term -pos=bottom -raw win python %
现在就一切正常了. /bin/win
脚本的作用就是把一个终端的编码转化为utf-8编码再输出.
你用 msys 里面的 python 不就行了?
你说的对, 我刚刚试了, 直接安装pacman版本的python就没有这个问题了😂
下次提 issue 应该先把自己运行环境,vim 版本号什么说清楚。
When I run a python file with
Chinese character cannot be displayed properly: