2017년 1월 3일 화요일

python 3 thread

import _thread

# Define a function for the thread
def mythread():
   while 1:
      print ("test")


# Create two threads as follows
try:
   _thread.start_new_thread( mythread, () )
except:
    print ("thread error")

while 1:
   pas

2017년 1월 1일 일요일

hold on button(pygame)

import pygame


pressed = Falsepygame.init()
pygame.display.set_mode((200,200))
while True:

        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.QUIT:
                    pygame.quit()
                else:
                    print "Unrecognized key"            if event.type == pygame.KEYUP:
                print("  ___   ")

        keys = pygame.key.get_pressed()
        if keys[pygame.K_UP]:
            print("UP")
        if keys[pygame.K_DOWN]:
            print("DOWN")
        if keys[pygame.K_LEFT]:
            print("L")
        if keys[pygame.K_RIGHT]:
            print("R")
        else:
            print ("?")