Python ÓÎÏ·³õѧ
import sys, pygame, time
size = width, height = 700,700
fontColor = (0,0,255)
class walk:
'''This is a game about war.
Just like war 3.'''
def __init__(self):
'''Init the screen.
Get param and init the screen'''
#print ('this is init funnction')
def initMainGraph(self):
print ('¤³¤³¤Ç¥á¥ó»Ãæ¤ò³õÆÚ»¯')
def outputChar(self, screen, imgRect):
oc = pygame.font.SysFont('Arial', 36)
str = 'Let\'s Start the Game'
wid = 100
hei = 300
for i in str:
surf = oc.render(i,0,fontColor)
rec = surf.get_rect()
wid += 20
rec.topleft = (wid, hei)
screen.blit(surf,rec)
pygame.display.flip()
time.sleep(0.25)
def slow(self, screen, imgRect):
print ('slow show')
def runGame():
pygame.init()
screen = pygame.display.set_mode(size)
bgimg = pygame.image.load('world.png').convert_alpha()#load bgImage
imgRect = bgimg.get_rect() #get the Area of the Image
screen.blit(bgimg,imgRect)
pygame.display.flip()
luxs = walk() #create a object
luxs.outputChar(screen, imgRect)
time.sleep(3)
while 1:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit(0)
runGame()
³õѧÕߣ¬×öÁËÒ»¸öСÀý×Ó£¬ÏÔʾ±³¾°Í¼ºÍÎı¾
Ïà¹ØÎĵµ£º
1.½âÊÍÐÔ ¿ÉÒÔÖ±½Ó´ÓÔ´´úÂëÔËÐгÌÐò.ÔÚ¼ÆËã»úÄÚ²¿,Python½âÊÍÆ÷°ÑÔ´´úÂëת»»³É³ÆΪ×Ö½ÚÂëµÄÖмäÐÎʽ,È»ºóÔÙ°ÑËü·Òë³É¼ÆËã»úʹÓõĻúÆ÷ÓïÑÔ²¢ÔËÐÐ.
2.#·ûºÅºóÃæµÄÄÚÈݶ¼ÊÇ×¢ÊÍ.
3.ÔÚ×Ö·û´®ÖÐÐÐÄ©µÄ'\'±íʾÏÂÒ»ÐеÄÄÚÈݺÍÉÏÒ»ÐÐÊǽÓ×ŵÄ;×Ö·û´®Ç°¼ÓÒ»¸ör±íʾijЩ²»ÐèҪתÒå·ûÄÇÑùµÄÌرð´¦ÀíµÄ×Ö·û´®;ÔÚ´¦ÀíÎı¾ÎļþµÄʱºòÊ ......
ת×Ô http://www.javaeye.com/topic/561786
ÔÌû£ºhttp://www.cnblogs.com/jingleguo/archive/2008/06/02/1211820.html
µ±pythonÖм䴦Àí·ÇASCII±àÂëʱ£¬¾³£»á³öÏÖÈçÏ´íÎó£º
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position 1: ordinal not in range(128)
0x??Êdz¬³ö128µÄÊý×Ö£¬pythonÔÚĬÈϵ ......
תÔØ×Ô£ºhttp://hi.baidu.com/myitlyj/blog/item/25586bd7088ba3dba044df6b.html
ÔÚ³ÌÐòÖÐʹÓÃÅäÖÃÎļþÀ´Áé»îµÄÅäÖÃһЩ²ÎÊýÊÇÒ»¼þºÜ³£¼ûµÄÊÂÇ飬ÅäÖÃÎļþµÄ½âÎö²¢²»¸´ÔÓ£¬ÔÚpythonÀï¸üÊÇÈç´Ë£¬ÔÚ¹Ù·½·¢²¼µÄ¿âÖоͰüº¬ÓÐ×öÕâ¼þÊÂÇéµÄ¿â£¬ÄǾÍÊÇConfigParser£¬ÕâÀï¼òµ¥µÄ×öһЩ½éÉÜ¡£
ConfigParser½âÎöµÄÅäÖÃÎļþµÄ¸ñÊ ......
1. 9.7 ÕýÔò±í´ïʽÓë re Ä£¿é
Ò»¸öÕýÔò±í´ïʽ¾ÍÊÇÒ»¸öÓÃÀ´±íʾijÖÖģʽµÄ×Ö·û´®¡£ËüÄÜ°ïÖúÄã·½±ãµÄ¼ì²éÒ»¸ö×Ö·û´®ÊÇ·ñÓëijÖÖģʽƥÅä¡£
re Ä£¿éʹ Python ÓïÑÔÓµÓÐÈ«²¿µÄÕýÔò±í´ïʽ¹¦ÄÜ¡£ compile º¯Êý¸ù¾ÝÒ»¸öģʽ×Ö·û´®ºÍ¿ÉÑ¡µÄ±êÖ¾²ÎÊýÉú³ÉÒ»¸öÕýÔò±í´ïʽ¶ÔÏ󡣸öÔÏóÓµÓÐһϵÁз½·¨ÓÃÓÚÕýÔò±í´ïʽƥÅäºÍÌæ»»¡£ re Ä£ ......
×î½üÏÂÔØÁËÒ»·Ý×îеÄpython3.0Íæ¶ù
ûÏëµ½print(Hello world)¾ÍÄÑΪÁËÎÒ°ëÌì
ÎÊÌâ1£¬printº¯Êý
ºóÀ´¿´ÁËһϸüеÄÎĵµ²ÅÖªµÀ£¬3.0ÒÔºóprintÒѾ±»·â×°³Éº¯ÊýÁË
¶øÎÒ»¹Ò»Ö±Ï°¹ß2.6µÄ print 'Hello World'ÐÎʽ£¬ º¹Ò»¸ö£¡
ÎÊÌâ2£¬notepadµÄutf8¸ñʽ
ÎÒʹÓÃnotepadдÁ˸ö²âÊÔÎļþ£¬±£´æΪutf8¸ñʽ
¸ñʽ´ó¸ÅÊÇ:
test& ......