본문 바로가기

Code41

Flutter request.send()를 사용하여 응답 본문을 어떻게 가져올 수 있나요?, How to get response body with request.send() in dart 질문 I'm doing an api request uploading an image with var request = new http.MultipartRequest("POST", uri); var response = await request.send() in dart using flutter. I can then check the response code with for instance if (response.statusCode == 200) { print('ok'); } with other calls I can also get the response body with var result = response.body; however when using request.send() I can't seem t.. 2023. 8. 16.
Python 파이썬을 사용하여 파일 이름을 바꾸는 방법, How to rename a file using Python 질문 나는 a.txt를 b.kml로 변경하고 싶다. 답변 아래의 HTML을 한국어로 번역하되, HTML 태그와 태그 내의 텍스트는 영어로 유지합니다. import os os.rename('a.txt', 'b.kml') 사용법: os.rename('from.extension.whatever','to.another.extension') 2023. 8. 1.
Python 여러 개의 루프에서 탈출하는 방법은 무엇인가요?, How can I break out of multiple loops? 질문 다음 코드를 주어진 상태에서 (작동하지 않는 코드): while True: # Snip: 현재 상태를 출력 while True: ok = get_input("이 괜찮습니까? (y/n)") if ok.lower() == "y": break 2 # 이 부분이 작동하지 않습니다 :( if ok.lower() == "n": break # 메뉴와 다른 작업을 더 처리 이 작동하도록 만들 수 있는 방법이 있을까요? 아니면 입력 루프에서 빠져나오기 위해 체크를 하나 더 해야하고, 사용자가 만족하면 완전히 빠져나오기 위해 외부 루프에서 더 제한된 체크를 해야 할까요? 답변 내 첫 번째 직감은 중첩된 루프를 함수로 리팩토링하고 return을 사용하여 탈출하는 것입니다. 2023. 7. 20.
Python 리스트의 모든 순열을 생성하는 방법은 무엇인가요?, How do I generate all permutations of a list? 질문 리스트의 모든 순열을 생성하는 방법은 무엇인가요? 예를 들어: permutations([]) [] permutations([1]) [1] permutations([1, 2]) [1, 2] [2, 1] permutations([1, 2, 3]) [1, 2, 3] [1, 3, 2] [2, 1, 3] [2, 3, 1] [3, 1, 2] [3, 2, 1] 답변 표준 라이브러리의 itertools.permutations을 사용하세요: import itertools list(itertools.permutations([1, 2, 3])) 여기에서 적용된 itertools.permutations의 구현 예시입니다: def permutations(elements): if len(elements) AB AC AD B.. 2023. 6. 30.