[英]Notepad++ Python script can't open file with special characters in filename
我需要通過記事本++將某些文件的編碼更改為UTF-8。 我為Python腳本插件找到了該腳本,該腳本可更改文件夾中所有文件的編碼:
import os;
import sys;
filePathSrc="C:\\Users\\" # Path to the folder with files to convert
for root, dirs, files in os.walk(filePathSrc):
for fn in files:
if fn[-4:] == '.txt': # Specify type of the files
notepad.open(root + "\\" + fn)
notepad.runMenuCommand("Encoding", "Convert to UTF-8")
notepad.save()
notepad.close()
它對我很有用,除非foler中的文件在文件名中具有異常的非英語字符(例如é,Ø,ß等)。 關於此文件,Notepad ++顯示了創建新文件“ C:\\ Somefile.txt不存在。創建它嗎?”的建議。 而不是打開它。
請幫助教Notepad ++,此腳本也會打開此文件。
我認為這個問題是由於單詞之間的間隔而出現的。 Notepad ++有這樣的問題。 如果可行,這里有一個解決方案http://sourceforge.net/p/notepad-plus/discussion/331753/thread/bdf6db82
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.