분류 전체보기980 Python argparse 명령 줄 플래그 (옵션) 인자 없이, Python argparse command line flags without arguments 질문 명령 줄 인수에 선택적 플래그를 추가하는 방법은 무엇인가요? 예를 들어, 다음과 같이 작성할 수 있도록 하려면 python myprog.py 또는 python myprog.py -w 다음을 시도해보았습니다. parser.add_argument('-w') 하지만 다음과 같은 오류 메시지가 표시됩니다. Usage [-w W] error: argument -w: expected one argument 이는 -w 옵션에 대한 인수 값이 필요하다는 것을 의미합니다. 플래그만 받아들이는 방법은 무엇인가요? 이 질문에 대해서는 http://docs.python.org/library/argparse.html을(를) 참조하십시오. 답변 As you have it, the argument w is expecting .. 2023. 10. 18. Python 함수 호출 시간 초과, Timeout on a function call 질문 I'm calling a function in Python which I know may stall and force me to restart the script. How do I call the function or what do I wrap it in so that if it takes longer than 5 seconds the script cancels it and does something else? 답변 UNIX에서 실행 중이라면 signal 패키지를 사용할 수 있습니다: In [1]: import signal # 타임아웃을 위한 핸들러 등록 In [2]: def handler(signum, frame): ...: print("영원히 끝났습니다!") ...: raise Exception.. 2023. 10. 18. Python 오류 "(유니코드 오류) 'unicodeescape' 코덱은 위치 2-3의 바이트를 디코드 할 수 없습니다: 잘린 \UXXXXXXXX 이스케이프" [중복], Error "(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: trunc.. 질문 I'm trying to read a CSV file into Python (Spyder), but I keep getting an error. My code: import csv data = open("C:\Users\miche\Documents\school\jaar2\MIK\2.6\vektis_agb_zorgverlener") data = csv.reader(data) print(data) I get the following error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape I have tried to replace the \ w.. 2023. 10. 18. Python requests를 사용하여 이미지를 다운로드하는 방법은 다음과 같습니다., How to download image using requests 질문 나는 파이썬의 requests 모듈을 사용하여 웹에서 이미지를 다운로드하고 저장하려고 시도하고 있습니다. 다음은 사용한 (작동하는) 코드입니다: img = urllib2.urlopen(settings.STATICMAP_URL.format(**data)) with open(path, 'w') as f: f.write(img.read()) requests를 사용한 새로운 (작동하지 않는) 코드는 다음과 같습니다: r = requests.get(settings.STATICMAP_URL.format(**data)) if r.status_code == 200: img = r.raw.read() with open(path, 'w') as f: f.write(img) requests에서 응답으로부터 사용할 속성.. 2023. 10. 17. 이전 1 ··· 48 49 50 51 52 53 54 ··· 245 다음