728x90
반응형
# 결과값
hello, world!
hello, python!
['hello,', 'world!\nhello,', 'python!']
['hello,', 'world!\nhello, python!']
['hello', '', 'world!', 'hello', '', 'python!']
['1', '2', '3', '4']
1+2+3+4
10
import re
# split
str01 = 'hello, world!\nhello, python!'
print(str01)
arr01 = str01.split(' ')
print(arr01)
arr02 = str01.split(' ', 1)
print(arr02)
arr03 = re.split(r'[\s]|[,]', str01)
print(arr03)
# join
arr04 = ['1','2','3','4']
print(arr04)
a = '+'.join(arr04)
print(a)
print(eval(a))
728x90
반응형
'Language > Python' 카테고리의 다른 글
[python]control_for (0) | 2020.10.07 |
---|---|
[python]control_if (0) | 2020.10.07 |
[python]regex, r정규식 (0) | 2020.10.07 |
[python]operation (0) | 2020.10.07 |
[Python] 기초 (0) | 2020.10.06 |