일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Apache
- Python
- django
- PostgreSQL
- google apps script
- dataframe
- matplotlib
- list
- gas
- Kotlin
- PySpark
- math
- string
- Excel
- Redshift
- hive
- PANDAS
- Github
- GIT
- array
- SQL
- numpy
- Java
- Google Spreadsheet
- Mac
- 파이썬
- Google Excel
- c#
- Tkinter
- Today
- Total
목록Python/Python Basic (84)
달나라 노트

dictionary를 JSON data로 바꾸고 .json 파일을 생성해봅시다. - 참고 = dictionary json 변환 https://cosmosproject.tistory.com/758 import json dict_data = { "category": "fruits", "product_cnt": 2, "product": { "Apple": { "price": 20000, "weight": 3 }, "Watermelon": { "price": 18000, "screen_size": 2 }, } } json_data = json.dumps(dict_data) print(json_data) print(type(json_data)) with open('json_data.json', 'w') as f:..
JSON (JavaScript Object Notation) 데이터는 프로그래밍에서 자주 쓰이는 형태의 데이터입니다. 다양한 정보를 보고 다루기 쉽게 저장할 수 있죠. 기본적으로 JSON data는 Python의 dictionary type과 매우 유사합니다. Python의 dictionary를 JSON 형태의 string으로 변환하기 위해서는 json library의 dumps method를 사용하면 됩니다. Syntax json.dumps(dictionary, indent=n) - dictionary JSON 형태의 string으로 변환할 dictionary 입니다. - indent = n optional한 parameter입니다. 명시하지 않아도 되며 명시할 경우 출력할 때 더 보기 쉽게 n개 만큼..
islower() method는 string에 적용할 수 있으며, 문자열에 포함된 모든 알파벳이 모두 소문자일 경우 True를 return합니다. 문자열에 포함된 알파벳 중 하나라도 대문자일 경우 False를 return합니다. isupper() method는 string에 적용할 수 있으며, 문자열에 포함된 모든 알파벳이 모두 대문자일 경우 True를 return합니다. 문자열에 포함된 알파벳 중 하나라도 소문자일 경우 False를 return합니다. Syntax string.islower() string.isupper() 사용법은 간단합니다. 두 method 모두 그냥 string에 적용하면 됩니다. str_test = 'abcde' print(str_test.islower()) -- Result T..
count() method는 어떤 string 속에서 원하는 텍스트가 몇개나 포함되어있는지를 return해줍니다. Syntax string.count(text) count() method는 string에 적용할 수 있는 method입니다. - text string에서 개수를 셀 문자입니다. 예시를 보시죠. str_test = 'apple_banana_pineapple_watermelon' val_cnt = str_test.count('a') print(val_cnt) -- Result 6 - str_test.count('a') str_test 변수에 있는 문자열에서 a라는 텍스트가 몇개 존재하는지 세라는 의미입니다. apple_banana_pineapple_watermelon a는 빨간색 bold체로 표..