会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132365个问题

老师,代码是照着敲的,可是运行的时候提示 'Tank' object has no attribute 'imges'

代码如下:

pygame
_display = pygame.display
COLOR_BLACK = pygame.Color(,,)    COLOR_RED = pygame.Color(,,)    version = MainGame():    window = SCREN_HWIDTH = SCREN_WIDTH = TANK_P1 = ():
        startGame():    _display.init()    MainGame.window = _display.set_mode([MainGame.SCREN_WIDTH,MainGame.SCREN_HWIDTH])    MainGame.TANK_P1 = Tank(, )  _display.set_caption(+ version)
        :
            MainGame.window.fill(COLOR_BLACK)    .getEvent()    MainGame.window.blit(.getTextSurface(%),(,))
            MainGame.TANK_P1.displayTanck()
            _display.update()  getEvent():    eventList = pygame.event.get()    event eventList:
            event.type == pygame.QUIT:
                .endGame()
            event.type ==  pygame.KEYDOWN:
                event.key == pygame.K_LEFT:    ()
                event.key == pygame.K_RIGHT:
                    ()
                event.key == pygame.K_UP:
                    ()
                event.key == pygame.K_DOWN:
                    ()
                event.key == pygame.K_SPACE:
                    ()
    getTextSurface(,text):
        pygame.font.init()
        font = pygame.font.SysFont(,)
        textSurface = font.render(text,,COLOR_RED)
        textSurface
    endGame():    ()
        ()    Tank():
    (,left,top):
        .iamges = {
            :pygame.image.load() , :pygame.image.load(),
            :pygame.image.load(),
            :pygame.image.load()
        }
        .directtion = .image = .imges[.directtion]    .rect = .image.get_rect()
        .rect.left = left
        .rect.top = top
    move():     shot():   displayTanck():        .image = .image[.directtion]
        MainGame.window.blit(.image,.rect)
MyTanck(Tank):    ():
        EnemyTank(Tank):    ():
        Bullet():    ():
        move():
        displayBulet():
        Explode():
    ():
        displayExplode():      Wall():    ():
        displayWall():
        Music():    ():
        MainGame().startGame()

运行结果:

blob.png

Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 37741楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Linux 37742楼


pymysql
con=pymysql.connect()
cursor=con.cursor()
:
    spl=cursor.execute(sal)
    con.commit()
:
    ()
    con.rollback()
:
    con.close()

老师看看我这什么问题,我一执行就出现下面报错

Traceback (most recent call last):

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\connections.py", line 583, in connect

    **kwargs)

  File "C:\Program Files (x86)\Python37-32\lib\socket.py", line 707, in create_connection

    for res in getaddrinfo(host, port, 0, SOCK_STREAM):

  File "C:\Program Files (x86)\Python37-32\lib\socket.py", line 748, in getaddrinfo

    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

socket.gaierror: [Errno 11001] getaddrinfo failed


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "D:/python/pythondemo/com/插入数据.py", line 2, in <module>

    con=pymysql.connect('localhosrt','root','sen6263234','pythondemo',3306)

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\__init__.py", line 94, in Connect

    return Connection(*args, **kwargs)

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\connections.py", line 325, in __init__

    self.connect()

  File "C:\Users\acer\AppData\Roaming\Python\Python37\site-packages\pymysql\connections.py", line 630, in connect

    raise exc

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhosrt' ([Errno 11001] getaddrinfo failed)")


Python 全系列/第五阶段:数据库编程/mysql的使用 37743楼
WEB前端全系列/预科阶段:职业规划/学习方法/程序员的职业规划 37747楼
Python 全系列/第一阶段:Python入门/控制语句 37750楼
JAVA 全系列/(旧的隐藏)第七阶段:JAVA 高级技术/Linux 37751楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637