a='hello world'
a[0]
h
a[6]
w
- 변수에 저장
a='hello world'
- 자료형 확인하기:
type()
type(a)
<class 'str'>
- 사용가능한 메서드 확인
dir()
dir(a)
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__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', 'isascii', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'removeprefix', 'removesuffix', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
- 메서드 사용하기: 변수 뒤에 . 을 붙이고 메서드를 사용
a.swapcase()
'HELLO WORLD'
'파이썬 수업 > 파이썬 기초문법' 카테고리의 다른 글
[파이썬] 6. if(조건문) (0) | 2023.06.24 |
---|---|
[파이썬 기초문법] 8. 함수 (0) | 2023.05.20 |
[파이썬 기초문법] 6. 조건문(if) (0) | 2023.05.20 |
[파이썬 기초문법] 3. 리스트 (0) | 2023.05.06 |
[파이썬 기초문법] 1.변수/입출력 (0) | 2023.04.29 |
Comment