.upper()
.lower()
.replace(str1, str2)
.find(str)
.count(str)
.split()
.split(,)
''.join([str1, str2])
: str1 str2
','.join([str1, str2])
: str1, str2
공백 삭제 lstrip
rstrip
strip
format 메서드
'Hello {0}'.format('world')
>> 'Hello world'
'Hello {0} {1} {2}'.format('a', 'b', 'c')
= 'Hello {} {} {}'.format('a', 'b', 'c')
>> 'Hello a b c'
fstring f'Today is {month} {date}'
id(변수)
: 변수의 주소값
# 복사
x = [1, 2, 3, 4, 5]
y = x.copy()
# 다차원 복사
import copy
x = [[1, 2], [3, 4, 5]]
y = copy.deepcopy(x)
가변 매개 변수: 개수가 정해지지 않는 매개 변수
튜플형
def print_fruits(*args):
/ print_fruits('apple', 'orange', 'mango')
def post_info(*tags, title, num):
/ post_info('#파이썬', '#함수', title = 파이썬 초격차 공부, num = 2)
딕셔너리형
def comment_info(**kwargs):
for key, value in kwargs.items():
print(f'{key}: {value}')
/ comment_info('컴순이', '12/23')
변수 중 가장 마지막에 사용해야 함
def minus_one(a):
return a - 1
/ minus_one(10)
(lambda a: a - 1)(10)
minus_one = lambda a: a - 1
/ minus_one(10)
lambda b: True if b > 0 else False
items = list(map(lambda x: x.strip(),items)
filter(함수, 리스트)
: 리스트 중 함수가 True인 것들만 return