저는 여러 컴퓨터에서 계속 업데이트되도록 Pastebin을 사용하여 파이썬 프로그램의 코드를 저장하고 있습니다. 나는 지금 비슷하게 업데이트 된 도움말 창을 유지하려고 노력 중이다. .chm 파일을 사용하여 전체 도움말 대화 상자를 단일 파일로 유지할 수 있지만 파일이 텍스트로 잘 변환되지 않는 것을 보았습니다. 어떻게 .CHM 도움말 파일을 파이썬 텍스트로 저장할 수 있습니까?
은 내가 메모장 파일 ("Viewhlp.chm")를 열고 Pastebin에 텍스트를 복사 한 다음 .chm 파일을 다시 시도하는 아래의 스크립트를 사용 Microsoft에서 샘플 .chm 파일을 사용했다. 이것은 작동하지 않습니다. 직접 열 때 "파일을 열 수 없습니다"라는 메시지가 나타나며 PyWin32에서 무시됩니다. 파이썬으로로드 할 수있는 도움말 대화 상자의 다른 파일 형식이 있습니까?import urllib2, sys
helpUrl = "http://pastebin.com/raw.php?i=a8rF2i8a"
originalPath = "Viewhlp.chm"
newPath = "NewHlp.chm"
try:
helpData = urllib2.urlopen(helpUrl)
except urllib2.URLError:
sys.exit()
currentHelp = helpData.read()
with open(newPath, mode="wb") as helpFile:
helpFile.write(currentHelp)
# briefly display using PyWin32 or just open the chm files directly
import win32help
win32help.HtmlHelp(0, None, win32help.HH_INITIALIZE, None)
link = win32help.HH_AKLINK()
link.indexOnFail = 1
link.url = ""
link.msgText = ""
link.msgTitle = ""
link.window = ""
win32help.HtmlHelp(0, originalPath, win32help.HH_KEYWORD_LOOKUP, link)
win32help.HtmlHelp(0, newPath, win32help.HH_KEYWORD_LOOKUP, link)