-2
from sense_hat import SenseHat
from time import sleep, strftime
sense = SenseHat()
# ------------------------------------------------
# DATA
# ------------------------------------------------
# Colours
colours = {
'r' : [255, 0, 0],
# Add orange, yellow, green, blue, indigo, violet here
'o' : [255, 125, 0],
'y' : [255, 255, 0],
'g' : [0, 255, 0],
'b' : [0, 0, 255],
'i' : [75, 0, 130],
'v' : [51, 2, 170],
'n' : [135, 80, 22],
'w' : [255, 255, 255],
'e' : [0, 0, 0] # e stands for empty/black
}
# Pictures
with open("pictures.txt", "r") as f:
all_pics = f.readlines()
# ------------------------------------------------
# FUNCTIONS
# ------------------------------------------------
# Display a given picture string on the sense HAT
# ------------------------------------------------
def display_pic(pic_string):
# Get rid of newline and split the line into a list
pic_string = pic_string.strip("\n")
pic_string = pic_string.split(",")
# Look up each letter in the dictionary of colours and add it to the list
pic_list = []
for letter in pic_string:
pic_list.append(colours[letter])
# Display the pixel colours from the file
sense.set_pixels(pic_list)
# ------------------------------------------------
# MAIN PROGRAM
# ------------------------------------------------
sense.clear()
display_pic(all_pics[7]
it show this-----> SyntaxError: unexpected EOF while parsing
를 실행할 때마다. 코드를 편집 할 수있는 방법을 알려 주셔서 감사합니다. 나는 라스베리 파이 웹 사이트에있는 지침을 따랐다. 나는 감각 HAT를 사용하여 출현 달력을 만들고 있는데, 감각 HAT 쇼 사진을 만들 것을 기대했다.그것은 구문 에러를 보여줍니다 예기치 않은 EOF를 구문 분석하는 동안 내가이 코드는이 문제를 해결하기 위해 말해주십시오 라즈베리 파이 감지 HAT에 이미지를 표시하는 코드를
display_pic'후 닫는 ')'누락 (all_pics [7]' – CoryKramer