리스트 데이터
a = ['BlockDMask', 'python', 'example', 'happy new year']
result1 = ".\n".join(a)
result2 = "".join(a)
print("result1",result1)
print("result2",result2)
result1
BlockDMask.
python.
example.
happy new yearresult2
BlockDMaskpythonexamplehappy new year
문자열.split()
문자열.split('구분자')
문자열.split('구분자', 분할횟수)
문자열.split(sep='구분자', maxsplit=분할횟수)
리스트 데이터
b = "BlockDMask python example happy new year"
r1 = b.split()
print(r1)
출력 결과 - r1
['BlockDMask', 'python', 'example', 'happy', 'new', 'year']
리스트 데이터
s = "aa.bb.cc.dd.ee.ff.gg"
print(f's : {s}')
출력결과 - 기본 s
s: aa.bb.cc.dd.ee.ff.gg
r0 = s.split()
-> 띄워쓰기로 분할
r1 = s.split('.')
-> .분할자 설정
print(f"s.split() : {r0}")
print(f"s.split('.') : {r1}")
출력결과 - 분할 s
s.split() : ['aa.bb.cc.dd.ee.ff.gg']
-> 일반 분할
s.split('.') : ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg']
->. 구분자 이용 분할
대문자로 upper()
s = "BlockDMask"
r1 = s.upper()
print(f"{s}.upper() : {r1}")
출력결과 - 대문자
BlockDMask.upper() : BLOCKDMASK
소문자로 lower()
r2 = s.lower()
print(f"{s}.lower() : {r2}")
출력결과 - 소문자
BlockDMask.lower() : blockdmask
문자열.count(x)
s = "blockdmask"
r1 = s.count('k')
문자열.rfind(x)
s = "blockdmask"
r1 = s.find('k')