문자열 1
+++++++++++++++++++++++++++++++++++
파이썬 문자열 관련 함수
>>> for data in dir(str):
print (data)
+++++++++++++++++++++++++++++++++++
__________________________________________________________
__add__
__class__
__contains__
__delattr__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__getitem__
__getnewargs__
__gt__
__hash__
__init__
__iter__
__le__
__len__
__lt__
__mod__
__mul__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__rmod__
__rmul__
__setattr__
__sizeof__
__str__
__subclasshook__
capitalize
casefold
center
count
encode
endswith
expandtabs
find
format
format_map
index
isalnum
isalpha
isdecimal
isdigit
isidentifier
islower
isnumeric
isprintable
isspace
istitle
isupper
join
ljust
lower
lstrip
maketrans
partition
replace
rfind
rindex
rjust
rpartition
rsplit
rstrip
split
splitlines
startswith
strip
swapcase
title
translate
upper
zfill
-------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------
capitalize 는 첫문자를 대문자로, 나머지 문자를 소문자로 바꾸어준다.
-----------------------------------------------------------------------------
>>> # capitalize()
>>> "PYTHON".capitalize()
'Python'
>>> "python is powerful".capitalize()
'Python is powerful'
>>>
>>> "my NaMe is kiM jUN HYEON".capitalize()
'My name is kim jun hyeon'
---------------------------------------------------------------------------------------------------------------------------------------------------------------
count(keyword, [start, [end]])
: 임의의 문자열에서 'keyword'가 start 와 end 사이에서 몇 번 발생하는지 세준다.
특정 문자열을 세는것도 가능하다.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
>>> "hello my name is kim jun hyeon".count('n', 5)
3
>>> "Hello Hello Hello Hello".count("Hello", 0)
4
---------------------------------------------------------------------------------------------------------------------------------------------------------------
find(keyword, [start,[end]])
문자열 keyword 가 나타나는 첫 번째 인덱스를 반환합니다. start, end를 지정하면 슬라이싱 한 것과 같은 효과를 볼수 있다.
keyword를 찾지 못한 경우 -1 을 반환한다.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
len : 문자열 길이 함수
참고로 반복문에서 유용하게 사용된다.
시퀀스 자료형에는 문자열(string), 리스트(list) , 튜플(tuple) 등이 있는데 이러한 시퀀스 자료형들은 인덱싱(indexing) 접근이 가능하다.
---------------------------------------------------------------------------------------------------------------------------------------------------------------