0
아래와 같은 오류가 나타납니다. 그것은 공간으로 인해 경로 문제처럼 보입니다.Windows 경로의 공백 문자가 WindowsError : [오류 2]
>>> from _winreg import *
>>> aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
>>> print aReg
<PyHKEY at 03216070 (000001C8)>
>>> hKey = OpenKey(aReg, r"SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\LocalDumps")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
WindowsError: [Error 2] The system cannot find the file specified
올바르게 "Windows"로 올라갑니다.
>>> hKey = OpenKey(aReg, r"SOFTWARE\\Microsoft\\Windows\\")
>>> print hKey
<PyHKEY at 03216050 (000001A0)>
원시 문자열에서 백 슬래시를 두 번 사용하지 마십시오. 단일 백 슬래시에서 원시 문자열을 끝낼 수 없습니다. – eryksun
winreg.exe 또는 reg.exe를 사용하여 경로가 존재하는지 확인한 경우 아마도 32 비트 Python을 사용하고있을 것입니다. 'hKey = OpenKey (HKEY_LOCAL_MACHINE, r "SOFTWARE \ Microsoft \ Windows \ Windows 오류보고 \ LocalDumps", 0, KEY_READ | KEY_WOW64_64KEY)'와 같이 64 비트 키를 명시 적으로 열도록 액세스를 설정하십시오. – eryksun
[왜 파이썬에서 단일 백 슬래시 원시 문자열로 인해 구문 오류가 발생합니까?] (http://stackoverflow.com/questions/30283082/why-does-the-single-backslash-raw-string-in-python -cause-a-syntax-error) –