2026.04.06(Mon)

오유찬·2026년 4월 10일

DE

목록 보기
2/16
# Define a function called concat
def concat(**kwargs):

"""Concatenates keyword arguments into a single string with spaces."""

result = ""

# Iterate over the Python kwargs
for kwarg in kwargs.items():
result += " " + kwarg

return result

# Call the function
print(concat(start="Python", middle="is", end="great!"))

kwargs.iter() → dict has no attribute 'iteration'

파이썬3에는 iter() 메서드 존재하지 않는다. items(), keys(), values()가 iterator와 유사한 view 객체를 반환한다.

kwargs.items() → can only concatenate str (not tuple) to str

kwargs.items()를 반복문으로 돌리면 각 요소는 (key, value) 형태의 튜플로 반환된다. result는 문자열인데, 문자열에 튜플을 더하려고 해서 위와 같은 에러가 발생한 것이다.

kwargs.values()를 사용해서 value만 뽑아 문자열로 사용하면 해결되는 문제였다.

valueerror : 제공된 값이 허용 가능한 범위에 있지 않을 때

  • 타입은 맞았는데, 값이 잘못되서 불가함.
  • float('hello') : float는 문자열을 받기도 하는데, hello를 바꿔줄 숫자 값이 없다.

git revert

  • 이전 버전을 되살리고 커밋 만든다
  • 해당 커밋에서 변경된 모든 파일 복원
  • commit 없이 되돌리고 싶다.(staging에 가져오기) : git revert -n HEAD
    - -n : no commit
  • 편집기 열리는 것을 피하고 싶다. : --no-edit

만약 단일 파일만 되돌리고 싶다면 → git checkout
git checkout HEAD~1 -- report.md

  • staging 파일에 올라가 있다.

staging 영역에 있는 파일을 되돌리고 싶다면? → unstaging

  • 단일 파일 git restore --staged summary_statistics.csv
  • 모든 파일 git restore --staged

flat file : 구조화된 관계가 없는 레코드

  • 테이블 데이터를 담은 기본 텍스트 파일
  • 필드나 속성으로 이루어진 행, 레코드들의 모음
  • 각 필드에는 최대 한 가지 정보만 들어있다.
  • 헤더가 있을 수 있다. (데이터의 열의 내용, 해당하는 속성이나 특징이 무엇인지 설명)다
profile
열심히 하면 재밌다

0개의 댓글