还是需要配置一下,要不然容易遇到中文乱码
修改vim配置文件
vim配置文件一般位于/usr/share/vim中,文件名为vimrc
通过以下方式修改编码类型:
cd /usr/share/vim
vim vimrc
添加以下代码
"增加中文显示"
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
注意等号前后不要有空格,修改后再打开文件即可解决。
设置table缩进
同样在该文件中我们可以设置空格缩进
"设置tab长度为4字节"
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set autoindent
另外python3在运行时打印有中文也会乱码,此时需要进行如下操作:
以python3.6.8为例,找到安装目录
cd /usr/lib/python3.6
vi sitecustomize.py
如果文件存在的话,在开头加上这么几句:
# encoding=utf8
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')
重启后python服务已正常