Tip 1. 변수 이름 변경하기
Tip 2. 모듈 다운로드 받기
※ turtle은 기본 클래스이다.
> pip install heroes
import turtle as t
tim = t.Turtle
# as : Turtle을 t로 별명 짓기
● 학습 내용
1) 터플(Tuples)
: tuples 값은 불변성
2) colorgram 모듈을 활용해 색상 추출하기
Step 1. 초기
colors = colorgram.extract('color.jpeg', 20)
print(colors)
Step 2. 리스트 변환
colors = colorgram.extract('color.jpeg', 20)
rgb_colors = []
for color in colors:
rgb_colors.append(color.rgb)
print(rgb_colors)
Step 3. 터플 변환
colors = colorgram.extract('color.jpeg', 20)
rgb_colors = []
for color in colors:
r = color.rgb.r
g = color.rgb.g
b = color.rgb.b
new_color = (r, g, b)
rgb_colors.append(new_color)
print(rgb_colors)
● GIT URL : https://github.com/yooyijun15/Python/blob/main/Day18/main.py
Python/Day18/main.py at main · yooyijun15/Python
Contribute to yooyijun15/Python development by creating an account on GitHub.
github.com
'여러가지 > Python' 카테고리의 다른 글
Day 20 - 프로젝트 Snake Game (1) (0) | 2024.04.28 |
---|---|
Day 19 - Turtle Game (0) | 2024.04.27 |
Day 17 - Class(클래스) (0) | 2024.04.20 |
Day 16 - Object Oriented Programming(OOP) (0) | 2024.04.16 |
Day 15 - 프로젝트 Coffee Machine (0) | 2024.04.16 |