notepad++ 执行python脚本遇到问题

用notepad++批量转换文本编码格式gb2312->utf-8

结果在x64版本下找不到菜单 Plugins->plugin Manager.

结果在notepad++官网https://notepad-plus-plus.org/download/v7.4.2.html 找到

7.4.2版本,高于此版本的32bit、64bit版本都没有此菜单。只得安装7.4.2 32bit版本

编写python脚本

import os
import sys
from Npp import notepad # import it first!

filePathSrc="D:\\code\\working\\TDMSServer" # Path to the folder with files to convert
for root, dirs, files in os.walk(filePathSrc):
    for fn in files:
        if ((fn[-4:] == '.cpp') or (fn[-2:] == '.h')): # Specify type of the files
            notepad.open(root + "\\" + fn)      
            notepad.runMenuCommand("Encoding", "Convert to UTF-8")
            notepad.saveAs(root + "\\" + fn) # if you try to save/replace the file, an annoying confirmation window would popup.

            notepad.close()

运行,一直提示:“No module named 'Npp'”。

最后反复查找网页,在网页https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/d632d91e/发现了:

于是重新安装,并选择英文版。最终运行成功。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值