본문 바로가기

str2

Python TypeError: Unicode-objects must be encoded before hashing를 어떻게 수정할 수 있나요?, How to correct TypeError: Unicode-objects must be encoded before hashing? 질문 나는 이 오류를 가지고 있습니다: Traceback (most recent call last): File "python_md5_cracker.py", line 27, in m.update(line) TypeError: Unicode-objects must be encoded before hashing 나는 Python 3.2.2에서 이 코드를 실행하려고 할 때: import hashlib, sys m = hashlib.md5() hash = "" hash_file = input("해시가 있는 파일 이름은 무엇입니까? ") wordlist = input("워드리스트는 무엇입니까? (파일 이름을 입력하세요) ") try: hashdocument = open(hash_file, "r") except IO.. 2023. 11. 16.
Python 예외가 발생한 예외 설명과 스택 추적을 문자열로 모두 가져오기, Get exception description and stack trace which caused an exception, all as a string 질문 어떻게 잡힌 Exception (그 설명과 스택 추적)을 외부에서 사용하기 위해 str으로 변환할 수 있을까요? try: method_that_can_raise_an_exception(params) except Exception as e: print(complete_exception_description(e)) 답변 다음은 traceback 모듈을 참조하세요. 특히 format_exc() 함수입니다. 여기. import traceback try: raise ValueError except ValueError: tb = traceback.format_exc() else: tb = "에러 없음" finally: print tb 2023. 9. 12.