您的位置:首页 > 编程语言 > Python开发

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

2018-02-10 21:16 387 查看
用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 Nppp 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/发现了:



于是重新安装,并选择英文版。最终运行成功。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: