저는 Python을 처음 사용합니다 (염두에 두십시오). 초보자를위한 예제 중 하나에서 찌르기가 있습니다. 그 안에는 화면에 임의의 원을 그리는 프로그램이 있습니다. 그러나 문자를 문자로 복사하는 경우에도 여전히 행의 문법 오류는 circle.py
입니다. 누군가 나를위한 코드를 살펴볼 시간을 가져 주시겠습니까? (BTW, 초보자, 내가 파이썬의 확인을 이해하고있다. 나는 함수, 변수 및 객체 지향 프로그래밍을 얻을 수 있지만, 너무 많은 그 이후 모른다.) 어떤 도움구문 오류가 표시되지 않습니다.
1 import pygame, random
2
3 class Circle:
4 _minimum=100;_maximum=255
5 _colour=None
6 _properties=[]
7
8 def __init__(self,screen,width,height):
9 self.random_colour()
10 self.draw_circle(screen,width,height)
11
12 def draw_circle(self, screen, width, height):
13 x=random.randint(1,width)
14 y=random.randint(1,height)
15 size=random.randint(1,5)
16 self.properties=[x,y,size]
17 pygame.draw.circle(screen,self._colour,(x,y),size)
18
19 def random_colour(self)
20 red=random.randint(self._minimum,self._maximum)
21 green=random.randint(self._minimum,self._maximum)
22 blue=random.randint(self._minimum,self._maximum)
23 self._colour=[red,green,blue]
24
25 def clear_circle(self,screen):
26 pygame.draw_circle(screen,(0,0,0),(self._properties[0],self._properties[1],self._properties[2]
감사에서 모든.
블록간에 일관된 들여 쓰기가 필요하지 않습니다. – njzk2
njzk2가 맞습니다. 이것은 오류가 아닙니다. 들여 쓰기 수준마다 일관된 양의 공백을 사용하는 것이 좋은 생각이지만, 파이썬은 들여 쓰기 레벨을 이전 및 다음 행에 비례하여 만 봅니다. – Onyxite
동의 함. 각 블록 내에서 들여 쓰기가 일관되어야하지만 두 개의 다른 블록간에 들여 쓰기가 다를 수 있습니다. 파이썬은 불평하지는 않지만 다른 개발자들은 불평 할 것입니다. – SethMMorton