pip를 통해서 face-recognition 모듈을 설치하려는데 아래 사진과 같은 오류가 계속 발생합니다. pip 버전은 제일 최신 버전 파이썬 버전은 3.11.4 인터넷 보니 CMake를 설치하래서 일단 CMake 버전은 3.28.1입니다 아 dlib도 pip말고 직접 설치하래서 했더니 밑에 빨간 글자를 제외하고 위에 'subprocess.CalledProcessError' 부분과 똑같은 오류가 발생하더군요 이걸로 계속 고통받다 마지막으로 질문해봅니다 ㅠ
int sum2d_2(int ar[][COLS], int row); 에서 COLS 자리의 인덱스에 숫자를 적어주는 이유는 ar이라는 포인터의 행의 사이즈는 int * (COLS 자리의 인덱스) 이기 때문이다. 라고 해봤는데 이게 맞거나 비슷한 표현 일까요? 제 표현이 틀린 것 같아 답변자 분이 이해를 할 수 없을 것 같기도 하네요.. ㅈㅅ함미다.
그냥 그렇나 보다 하고 지나칠뻔한 걸 한번 의심을 하니 문제를 놓을 수가 없게 되었습니다. 1. int ar1[2][3] = { {1, 2, 3}, {4, 5, 6} }; int* pt; pt = &ar1[0][0]; for (int i = 0; i < 6; ++i) printf("%d %d ", pt[i], *(pt + i)); 2. int arr[2][3] = { {1, 2, 3}, {4, 5, 6} }; int* parr[2]; parr[0] = arr[0]; parr[1] = arr[1]; for (int i = 0; i < 2; ++i) printf("%p %p ", parr[i], *(parr + i)); 둘 다 똑같이 출력을 했는데 1번 예제는 값이, 2번 예제는 주소가 출력 되는 이유 그러니까 parr[i]가 주소를 출력하니 pt[i]도 주소를 출력 해야 할 것 같은데 값을 출력하는 이유가 궁금합니다. parr은 포인터의 배열이고 pt는 포인터라서? parr의 자료형은 int (*)[3]이고 pt의 자료형은 int*라서? 뭔가 연관이 있을 텐데 저는 어떤 연관이 있는 건지 쉽사리 연결 지을 수가 없더라구요. 꼭 알려주셨으면 합니다. 항상 좋은 답변 감사합니다.
#include <stdio.h> int main() { /* Assume that your input is : Hello 123 3.14 */ char str[255], tmp; int i = 0, i2 = 0; double d = 0.0; scanf("%s %d %lf", str, &i, &d); // POINT1 printf("%s %d %f\n", str, i, d); // or (see the difference) scanf("%c", &tmp); // POINT2 printf("My input was %c!!!\n", tmp); // POINT2_1 scanf("%s %d %d", str, &i, &i2); // POINT3 printf("%s %d %d\n", str, i, i2); // or (see the difference) char c; while ((c = getchar()) != '\n') putchar(c); printf("\n"); return 0; } 안녕하세요 강의를 듣다가 평소에는 무심코 지나쳤던 부분이 눈에 밟혀 질문 드립니다. POINT1에 정상적인 값들을 입력하고 Enter를 누르면 POINT2에서 '\n'이 입력되고 POINT2_1에서 '\n'이 출력된 것을 확인했습니다. 그렇다는 것은 버퍼에 '\n'이 남았다는 것을 알 수 있습니다. 여기서 궁금증이 생겼습니다. POINT2, POINT2_1을 지우고 실행하면 왜 POINT3에서 정상적인 값들을 입력했을 때 str에 '\n'이 입력되지 않는지 궁금합니다. 처음에는 printf() 함수가 알아서 버퍼를 비워주나 생각했었지만 POINT2, 2_1을 통해 그건 아니라는 것은 확인했습니다. 그래서 제 딴에 생각한 것은 'scanf() 함수에서 여러 개의 값들을 입력 받으면 (한 개의 값만 입력 받을 때와 달리) 버퍼에 남아있던 '\n'을 자동으로 무시해 주는 것이다.' 인데 이것이 맞는지 궁금합니다.
정수형 강의 내용 중 long 자료형 크기에 대해 궁금한 점이 생겨 질문드립니다! 64비트 기준으로, long 자료형이 4바이트라고 설명해 주셨는데, sizeof 연산자로 long 변수 크기를 확인할 경우 8바이트로 나오게 되어 질문드립니다. 제목과 같이 32와 64간 자료형의 크기를 비교한 자료가 있을까요?? 검색 결과 작성자마다 약간씩 차이를 보여 질문드립니다. 감사합니다.
안녕하세요 선생님 질문이 하나 있습니다. dp(6-5) = dp(1)이고 dp(6-3)은 dp(3)을 나타내고 이제 6번째 배열에서 Min(dp(1)+1, dp(3)+1)에서 최소값은 왼쪽 dp(1)+1이 아닌가요? 왜 dp(3)+1로 된건지 이해가 안갑니다. 대괄호가 기입이 안돼 소괄호로 대체합니다.
from typing import List from fastapi import FastAPI, Body, HTTPException, Depends from pydantic import BaseModel from sqlalchemy.orm import Session from database.orm import ToDo from database.connection import get_db from database.repository import get_todos from schema.response import ListToDoResponse, ToDoSchema app = FastAPI() @app.get("/") def heath_check_handler(): return {"ping": "pong"} todo_data = { 1: { "id": 1, "contents": "실전! FastAPI 섹션 0 수강", "is_done": True, }, 2: { "id": 2, "contents": "실전! FastAPI 섹션 1 수강", "is_done": False, }, 3: { "id": 3, "contents": "실전! FastAPI 섹션 2 수강", "is_done": False, }, } @app.get("/todos", status_code=200) def get_todos_handler( order: str | None = None, session: Session = Depends(get_db), ) -> ListToDoResponse: todos: List[ToDo] = get_todos(session=session) if order and order == "DESC": return ListToDoResponse( todos=[ToDoSchema.from_orm(todo) for todo in todos[::-1]] ) return ListToDoResponse( todos=[ToDoSchema.from_orm(todo) for todo in todos] ) @app.get("/todos/{todo_id}", status_code=200) def get_todo_handler(todo_id: int): todo = todo_data.get(todo_id) if todo: return todo raise HTTPException(status_code=404, detail="ToDo Not Found") class CreateToDoRequest(BaseModel): id: int contents: str is_done: bool @app.post("/todos", status_code=201) def create_todo_handler(request: CreateToDoRequest): todo_data[request.id] = request.dict() return todo_data[request.id] @app.patch("/todos/{todo_id}", status_code=200) def update_todo_handler( todo_id: int, is_done: bool = Body(..., embed=True) ): todo = todo_data.get(todo_id) if todo: todo["is_done"] = is_done return todo raise HTTPException(status_code=404, detail="ToDo Not Found") @app.delete("/todos/{todo_id}") def delete_todo_handler(todo_id: int): todo = todo_data.pop(todo_id, None) if todo: return raise HTTPException(status_code=404, detail="ToDo Not Found") from typing import List from pydantic import BaseModel class ToDoSchema(BaseModel): id: int contents: str is_done: bool class Config: orm_mode = True class ListToDoResponse(BaseModel): todos: List[ToDoSchema] from typing import List from sqlalchemy import select from sqlalchemy.orm import Session from database.orm import ToDo def get_todos(session: Session) -> List[ToDo]: return list(session.scalars(select(ToDo))) from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker DATABASE_URL = "mysql+pymysql://root:todos@127.0.0.1:3306/todos" engine = create_engine(DATABASE_URL, echo=True) SessionFactory = sessionmaker(autocommit=False, autoflush=False, bind=engine) def get_db(): session = SessionFactory() try: yield session finally: session.close() from sqlalchemy import Boolean, Column, Integer, String from sqlalchemy.orm import declarative_base Base = declarative_base() class ToDo(Base): __tablename__ = 'todo' id = Column(Integer, primary_key=True, index=True) contents = Column(String(256), nullable=False) is_done = Column(Boolean, nullable=False) def __repr__(self): return f"ToDo(id={self.id}, contents={self.contents}, is_done={self.is_done})" 에러가 납니다. 파이썬 콘솔 <input>:1: PydanticDeprecatedSince20: The from_orm method is deprecated; from schema.response import ToDoSchema from datagbase.orm import ToDo Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\pydevconsole.py", line 364, in runcode coro = func() ^^^^^^ File "<input>", line 1, in <module> File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import module = self._system_import(name, args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'datagbase' from database.orm import ToDo todo = ToDo(id=100, contents="test", is_done=True) ToDoSchema.from_orm(todo) <input>:1: PydanticDeprecatedSince20: The from_orm method is deprecated; set model_config['from_attributes']=True and use model_validate instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.5/migration/ Traceback (most recent call last): File "C:\Program Files\JetBrains\PyCharm 2023.3.2\plugins\python\helpers\pydev\pydevconsole.py", line 364, in runcode coro = func() ^^^^^^ File "<input>", line 1, in <module> File "C:\Users\manag\pyProject\todos\Lib\site-packages\typing_extensions.py", line 2499, in wrapper return arg(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\pydantic\main.py", line 1126, in from_orm raise PydanticUserError( pydantic.errors.PydanticUserError: You must set the config attribute from_attributes=True to use from_orm http://localhost:8000/docs#/default/get_todos_handler_todos_get 접속시 터미널 INFO: 127.0.0.1:56312 - "GET /docs HTTP/1.1" 200 OK INFO: 127.0.0.1:56312 - "GET /openapi.json HTTP/1.1" 200 OK 2024-01-23 16:06:15,108 INFO sqlalchemy.engine.Engine BEGIN (implicit) 2024-01-23 16:06:15,109 INFO sqlalchemy.engine.Engine SELECT todo.id, todo.contents, todo.is_done FROM todo 2024-01-23 16:06:15,109 INFO sqlalchemy.engine.Engine [cached since 826.5s ago] {} 2024-01-23 16:06:15,113 INFO sqlalchemy.engine.Engine ROLLBACK INFO: 127.0.0.1:56312 - "GET /todos HTTP/1.1" 500 Internal Server Error ERROR: Exception in ASGI application Traceback (most recent call last): File "C:\Users\manag\pyProject\todos\Lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 404, in run_asgi result = await app( # type: ignore[func-returns-value] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in call return await self.app(scope, receive, send) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\fastapi\applications.py", line 1054, in call await super().__call__(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\applications.py", line 123, in call await self.middleware_stack(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\middleware\errors.py", line 186, in call raise exc File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\middleware\errors.py", line 164, in call await self.app(scope, receive, _send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in call await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app raise exc File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\routing.py", line 762, in call await self.middleware_stack(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\routing.py", line 782, in app await route.handle(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\routing.py", line 297, in handle await self.app(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\routing.py", line 77, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app raise exc File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\routing.py", line 72, in app response = await func(request) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\fastapi\routing.py", line 299, in app raise e File "C:\Users\manag\pyProject\todos\Lib\site-packages\fastapi\routing.py", line 294, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\fastapi\routing.py", line 193, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\starlette\concurrency.py", line 40, in run_in_threadpool return await anyio.to_thread.run_sync(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\anyio\to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\anyio\_backends\_asyncio.py", line 2134, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run result = context.run(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\src\main.py", line 48, in get_todos_handler todos=[ToDoSchema.from_orm(todo) for todo in todos] ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\typing_extensions.py", line 2499, in wrapper return arg(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\manag\pyProject\todos\Lib\site-packages\pydantic\main.py", line 1126, in from_orm raise PydanticUserError( pydantic.errors.PydanticUserError: You must set the config attribute from_attributes=True to use from_orm
연결리스트 삭제 시 헤드노드가 NULL인 경우를 고려해야 하는 이유가 궁금합니다. 삭제 전에 삭제할 노드를 미리 찾는 과정이 수반되는데, 그 과정은 헤드노드가 NULL값이 아니라는 것을 전제로 이루어집니다. 따라서 삭제할 노드를 찾아서 삭제를 진행하는 단계까지 왔다는 것은 헤드노드가 NULL이 아니라는 것을 전제로 한다고 볼 수 있습니다. 그럼에도 불구하고 삭제를 진행하는 함수에서 헤드노드가 NULL인 경우를 고려하시고 이에 대한 예외처리 코드를 작성하셨는데, 혹시 그에 대한 이유가 있을까요?
안녕하세요. #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int main() { /* strcpy() and strncpy() */ // 1 char dest[100] = ""; // make sure memory is enough char source[] = "Start programming!"; //dest = source; // Error //dest = "Start something"; // Error strcpy(dest, source); puts(dest); return 0; } 라는 코드에서 주석 처리된 "dest = source;"과 "dest = Start something;"의 오류가 "expression must be a modifiable lvalue"임을 확인했습니다. 이는 dest가 배열의 이름이며, 배열의 이름은 메모리 갖지 않기 때문에 나타나는 오류인가요? 또 strcpy() 함수를 사용하지 않고 배열 dest에 source의 문자열을 넣으려면 다음처럼 코드를 작성하면 될까요? #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> int main() { /* strcpy() and strncpy() */ // 1 char dest[100] = ""; // make sure memory is enough char source[] = "Start programming!"; for (int i = 0; i < strlen(source); i++) dest[i] = source[i]; puts(dest); return 0; }
안녕하세요 강의를 듣고 궁금한 점이 생겨 질문 드립니다. strcmp() 함수가 문자열을 비교할 때 1 혹은 -1을 출력하는 기준이 아스키코드라고 알고 있습니다. Bananas와 Banana를 비교했을 때, 둘의 순서를 바꿈에 따라 값이 다르게 출력되는 것을 확인했습니다. 단일 문자는 첫 번째 인수의 아스키코드가 더 작으면 -1이 더 크면 1이 출력되는 것은 이해했습니다. 그런데 문자열은 어떤 방식으로 -1과 1이 출력되는지 잘 모르겠습니다. 늘 친절한 답변 감사합니다.
강사님께서 설명하시는 버블정렬에 대한 설명을 듣고 질문 드립니다. 해당 영상의 초기 부분에 버블정렬에 대해 설명을 해주시는데, 해당 설명이 버블정렬에 대한 설명이 맞는지 문의드립니다. 설명해주신 내용은 선택 정렬이 아닐까 생각이 듭니다. 버블정렬은 맨 왼쪽 부터(작은수) 정렬되는 것이 아닌 가장 오른쪽(큰 수)부터 정렬이 되는 것으로 알고 있습니다. 1회차에서 가장 큰 값이 정해지고 그 다음 회차를 반복하면서 그 다음 으로 큰 수가 정해지는 방식으로 알고 있는데요, 그런데 영상 속 설명에서는 가장 왼쪽 값(작은 수)가 정해지면 1회차가 종료되며, 그 뒤에 그 다음으로 작은 수를 구하는 방식으로 진행하는 것으로 설명하는 것으로 보입니다. 확인 부탁드립니다 감사합니다. 참조 링크: https://ko.wikipedia.org/wiki/%EB%B2%84%EB%B8%94_%EC%A0%95%EB%A0%AC
arr과 arr[0]모두 arr[0][0]을 가리키지만 arr의 타입은 int (*)[3]이고 arr[0]의 타입은 int* 이다. 따라서 arr + 1은 &arr[0] + 1이고 arr[0] + 1은 &arr[0][0] + 1이다. 이게 맞나요? arr과 arr[0] 모두 arr[0][0]을 가리키는데 포인터 산술 연산을 하면 결과가 다르게 나와서 헷갈렸는데 수박 선생님이 전에 답변해 주신 걸 보고 나름 이해를 해봤어요 선생님이 아마 arr과 arr[0]의 자료형이 다르다고 하셨던 거 같은데 맞나요? 그 때 답변을 봐도 제가 이해한 게 맞는 건지 확신이 안 드네요.