python #format() #** #딕셔너리 #str #bytes #encode #decode #슬라이스로리스트1 [Python] "효율적 개발로 이끄는 파이썬 실천 기술" 책 중요 내용 정리 - 2편 "효율적 개발로 이끄는 파이썬 실천 기술" 책 중요 내용 정리 - 2편 ⭐ 딕셔너리의 키에 대한 값을 연속된 스트링으로, str.format() 과 ** 이용 str.format() 메서드의 인수에 **와 함께 딕셔너리를 전달하면 키에 대한 값을 연속된 str으로 바꿔준다. 두번 째 줄에서 format을 정해놓고, 세번째 **d를 사용함으로써 딕셔너리의 각 키에 대한 값을 가져온다. 한 가지 재미있는 점은, books의 str 안에 사용하지 않는 키, 예를 들면 'a' ,가 들어가도 상관 없다는 것이다. 이 방법은 코딩 테스트에서 유용하게 사용될 것 같다. str, bytes 타입 - str: 사람이 읽고 쓰기 쉬운 문자열 - bytes: 컴퓨터가 다루기 쉬운 바이트열 str.encode()와 bytes.. 2024. 1. 4. 이전 1 다음