일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- SQL
- GIT
- string
- Google Excel
- Java
- Mac
- gas
- array
- hive
- django
- PostgreSQL
- PySpark
- Kotlin
- google apps script
- matplotlib
- 파이썬
- dataframe
- Google Spreadsheet
- math
- PANDAS
- Github
- Python
- c#
- Redshift
- Tkinter
- list
- numpy
- Apache
- Excel
- Today
- Total
목록Python/Python Basic (84)
달나라 노트
center() method는 텍스트에 적용할 수 있는 method이며 기존 텍스트를 가운데에 위치시키고 양쪽에 동일한 개수의 문자를 추가시키는 method입니다. Syntax string.center(length, text) - length 기존 텍스트 길이와 새롭게 추가할 문자의 길이를 모두 합하여 최종적으로 return될 텍스트의 길이입니다. - text 기존 텍스트 양쪽에 추가할 문자를 의미합니다. (길이가 1인 하나의 단일 문자만 허용됩니다.) str_test = 'apple' str_test = str_test.center(15, '@') print(str_test) -- Result @@@@@apple@@@@@ - str_test.center(15, '@') str_test 변수에는 appl..
capitalize() method는 텍스트에 적용할 수 있는 method이며, 가장 첫 글자를 대문자로 만들고 나머지 글자는 모두 소문자로 만들어줍니다. Syntax string.capitalize() 예시를 봅시다. str_test = 'helLO WoRlD' str_test = str_test.capitalize() print(str_test) -- Result Hello world str_test 변수에는 helLO WoRlD 라는 문자가 담겨있습니다. 대문자/소문자가 섞여있는 텍스트입니다. 근데 caplitalize() method를 적용시킨 이후의 결과를 보면 가장 첫 글자인 h만 대문자 H로 바뀌고 나머지는 모두 소문자로 바뀌었습니다. str_test = 'helLO WoRlD. hI Eve..
Syntax dictionary.keys() dictionary에 존재하는 모든 key를 return 합니다. dictionary.values() dictionary에 존재하는 모든 value를 return 합니다. dictionary.items() dictionary를 구성하는 모든 key, value 값을 tuple로 묶어서 return 합니다. 예시를 봅시다. dict_test = { 'key1': 1, 'key2': 2, 'key3': 3 } print(dict_test.keys()) -- Result dict_keys(['key1', 'key2', 'key3']) - dict_test.keys() dict_test에 keys() method를 적용했습니다. 그 결과 값을 보니 dict_keys(..
Syntax dictionary.setdefault(key, default_value) setdefault method는 dictionary에 적용할 수 있는 method이며 2개의 인자를 받습니다. - key setdefault method는 전달받은 key값에 대한 value를 dictionary에서 찾아 return 해줍니다. - default_value 만약 전달받은 key값이 dictionary에 없을 경우 default_value를 return합니다. dict_test = { 'key1': 1, 'key2': 2, 'key3': 3 } val_result_1 = dict_test.setdefault('key1', 10) print(val_result_1) -- Result 1 위 예시를 봅시다..