IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    [原]python手记(51)

    u010255642发表于 2015-12-30 11:52:31
    love 0

    python 类

    class Mytest(object):
        nownum=0
        def __init__(self,value=100):
            self.nownum=value
        def inCrease(self):
            self.nownum+=1
        def deCrease(self):
            self.nownum-=1
        def toString(self):
            return "当前值:"+str(self.nownum)


    xx1=Mytest()
    xx1.inCrease()
    print xx1.toString()
    xx1.inCrease()
    print xx1.toString()
    xx2=Mytest(10)
    xx2.inCrease()
    print xx2.toString()
    xx2.inCrease()
    print xx2.toString()


    ============================ RESTART: E:\test.py ============================
    当前值:101
    当前值:102
    当前值:11
    当前值:12
    >>> 

    pygame手记


    >>> import pygame
    >>> from pygame.locals import *
    >>> pygame.init()
    (6, 0)
    >>> screen=pygame.display.set_mode((500,550))
    >>> myfont=pygame.font.Font(None,80)

    >>> red=(255,0,0)
    >>> green=(0,255,0)
    >>> textImage=myfont.render("您好",True,red)
    >>> screen.fill(green)
    <rect(0, 0, 500, 550)>
    >>> screen.blit(textImage,(90,90))
    <rect(90, 90, 134, 56)>
    >>> pygame.display.update()




沪ICP备19023445号-2号
友情链接