2011-08-02 1 views
1

this question 다음에 Windows 단축키를 수정하기 위해 다음 Python 코드를 사용합니다.
영어 기반 바로 가기에서는 작동하지만 유니 코드 기반 바로 가기에서는 그렇지 않습니다.Python을 사용하여 Windows 유니 코드 바로 가기 수정

유니 코드을 지원하는이 (또는 다른) 코드 조각을 으로 어떻게 수정할 수 있습니까?

import re, os, pythoncom 
from win32com.shell import shell, shellcon 

shortcut_path = os.path.join(path_to_shortcut, shortcut_filename) 
shortcut = pythoncom.CoCreateInstance (shell.CLSID_ShellLink, None, pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) 
persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile) 
persist_file.Load (shortcut_path) 
destination1 = shortcut.GetPath(0)[0] 
destination2 = os.path.join(destination_path, destination_filename) 
shortcut.SetPath(destination2) 
persist_file.Save(shortcut_path, 0) 

은 유니 코드이다 다음과 같은 가정 : path_to_shortcut, shortcut_filename, destination_path, destination_filename

+0

유니 코드 바로 가기에 정확히 무엇이 발생합니까? – agf

+0

바로 가기를 사용하거나'shell' 클래스를 사용하는 경우에만이 문제가 발생합니까? 어쩌면 질문은 Windows 단축키뿐만 아니라 일반적으로 유니 코드를 사용하도록 확장되어야합니까? – Hnatt

답변

0

아마도 도움이 여기 찾고 : Python Unicode HOWTO

을 당신이해야 할 것 같은데요 그 각각이 문자열은 유니 코드로 올바르게 인코딩되었으며 변경 사항은 해당 인코딩을 보존해야합니다. 이 기사는 필요한 모든 정보를 제공해야합니다.