祖先结点不应该是他上层的所有结点吗,不包括上层节点的兄弟结点吗
请问老师,bug在哪儿啊?我真的没找出来
密码不知道是啥呀
老师问题如图所示,主要是关于对数函数的,还有还是之前那个。一塔为啥等于
老师,这里为什么要建两个类呀,一定要建吗
为什么我的客户端运行不出来啊
#coding=utf-8 from socket import * from threading import Thread def recv_data(): while True: # 接收服务端数据 recv_data = client_socket.recv(1024) print(f"服务器端说:{recv_data.decode('gbk')}") def send_data(): while True: msg = input(">") client_socket.send(msg.encode("gbk")) if msg == "end": break if __name__ == '__main__': client_socket=socket(AF_INET,SOCK_STREAM) client_socket.connect(("127.0.0.1",8899)) t1=Thread(target=recv_data()) t2=Thread(target=send_data()) t1.start() t2.start() t1.join() t2.join() client_socket.close()
为何需要把StateHoliday的属性改为字符创呢
from urllib.request import Request, urlopen from urllib.parse import quote def get_html(ur1): headers = { "User_agent":"Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;TheWorld)" } request = Request(ur1, headers = headers) response = urlopen(request) return response.read().decode() def save_html(html,filename): with open(filename, 'w', encoding='utf-8') as f: f.write(html) def main(): ur1 = 'https://tieba.baidu.com/f/search/res?ie=utf-8&qw=%E5%88%BA%E5%AE%A2%E4%BF%A1%E6%9D%A1&red_tag=3423937163' html = get_html(ur1) save_html(html, filename) if __name__ == '__main__': main()
老师这个怎么解决呢
两个\\为什么输出之后变成一个\了,aabb\\cc→aabb\cc?
请问为什么要采用EeasyUi这种后台管理框架,我看网上很少有用这个框架。
请问老师怎么才能获得Ajax返回的属性值(列表),我想要将这些属性放到另一张表里该怎么实现。
老师,视频里在讲System类下的out变量有这句话:“成员变量out是PrintStream类型的”。 能不能解释一下是什么意思吗?
问题:已经写了while True循环为什么界面依然闪退?
报错:AttributeError: module 'pygame.display' has no attribute 'get'
代码:
""" 新增功能: 左上角文字的绘制: 左上角输出敌方坦克的数量 """ # 导入pygame模块 import pygame SCREEN_WIDTH = 700 SCREEN_HEIGHT = 500 BG_COLOR=pygame.Color(0, 0, 0) # 主类 class MainGame(): window = None def __init__(self): pass # 开始游戏 def startGanme(self): # 加载主窗口 # 初始化窗口 pygame.display.init() # 设置窗口的大小和显示 MainGame.window = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT]) # 设置窗口的标题 pygame.display.set_caption("坦克大战游戏测试1.03") # 循环窗口常亮 while True: # 给窗口设置一个填充色 MainGame.window.fill(BG_COLOR) # 获取事件 self.getEvent() pygame.display.update() # 结束游戏 def endGanme(self): print("谢谢,欢迎再次使用") exit() # 左上角文字的绘制 def getTextSufce(self): # 字体初始化模块 pygame.font.init() # 查看所有的字体名称 print(pygame.font.get_fonts()) # 获取字体Font对象 font = pygame.font.SysFont("黑体", 18) def getEvent(self): # 获取所有事件 eventList = pygame.display.get() # 遍历事件 for event in eventList: # 判断按下的键是关闭还是键盘按下 # 如果按的是退出,关闭窗口 if event.type == pygame.QUIT: self.endGanme() # 如果是键盘按下 if event.type == pygame.KEYDOWN: # 判断按下的是上、下 if event.key == pygame. K_LEFT: print("按下左键坦克向左移动") elif event.key == pygame.K_RIGHT: print("按下右键坦克向右移动") elif event.key == pygame.K_UP: print("按下上键坦克向上移动") elif event.key == pygame.K_DOWN: print("按下下键坦克向下移动") class Tank(): def __init__(self): pass # 移动 def move(self): pass # 射击 def shot(self): pass # 展示坦克的方法 def displayTank(self): pass # 我方坦克 class MyTank(Tank): def __init__(self): pass # 敌方坦克 class EnemyTank(Tank): def __init__(self): pass # 子弹类 class Bullet(): def __init__(self): pass # 移动 def move(self): pass # 展示子弹方法 def displayBullet(self): pass # 墙壁类 class Wall(): def __init__(self): pass # 展示墙壁的方法 def displayWall(self): pass # 爆炸类 class Explode(): def __init__(self): pass # 展示爆炸效果的方法 def displayExplode(self): pass # 音效类 class Music(): def __init__(self): pass # 播放音乐的方法 def play(self): pass if __name__ == "__main__": MainGame().startGanme()
pygame SCREEN_WIDTH = SCREEN_HEIGHT = BG_COLOR=pygame.Color() MainGame(): window = (): (): pygame.display.init() MainGame.window = pygame.display.set_mode([SCREEN_WIDTHSCREEN_HEIGHT]) pygame.display.set_caption() : MainGame.window.fill(BG_COLOR) .getEvent() pygame.display.update() (): () () (): pygame.font.init() (pygame.font.get_fonts()) = pygame.font.SysFont() (): eventList = pygame.display.get() event eventList: event.type == pygame.QUIT: .endGanme() event.type == pygame.KEYDOWN: event.key == pygame. K_LEFT: () event.key == pygame.K_RIGHT: () event.key == pygame.K_UP: () event.key == pygame.K_DOWN: () Tank(): (): (): (): (): MyTank(Tank): (): EnemyTank(Tank): (): Bullet(): (): (): (): Wall(): (): (): Explode(): (): (): Music(): (): (): __name__ == : MainGame().startGanme()
老师,我坦克按方向键不移动了是咋回事
pygametimerandom pygame.sprite Sprite SCREEN_WIDTH=SCREEN_HEIGHT=BG_COLOR=pygame.Color() TEXT_COLOR=pygame.Color() BaseItem(Sprite): (): pygame.sprite.Sprite.() MainGame(): window=my_tank=enemyTankList=[] enemyTankCount=myBulletList=[] enemyBulletList=[] explodeList=[] (): (): pygame.display.init() MainGame.window=pygame.display.set_mode([SCREEN_WIDTHSCREEN_HEIGHT]) MainGame.my_tank=Tank() .createEnemyTank() pygame.display.set_caption() : time.sleep() MainGame.window.fill(BG_COLOR) .getEvent() MainGame.window.blit(.getTextSuface(%(MainGame.enemyTankList))()) MainGame.my_tank MainGame.my_tank.live: MainGame.my_tank.displayTank() : MainGame.my_tank MainGame.my_tank=MainGame.my_tank.displayTank() .blitEnemyTank() .blitMyBullet() .blitEnemyBullet() .blitExplode() MainGame.my_tank MainGame.my_tank.live: MainGame.my_tank.stop: MainGame.my_tank.move() pygame.display.update() (): top=i (MainGame.enemyTankCount): left=random.randint() speed=random.randint() enemy=EnemyTank(lefttopspeed) MainGame.enemyTankList.append(enemy) (): explode MainGame.explodeList: explode.live: explode.displayExplode() : MainGame.explodeList.remove(explode) (): enemyTank MainGame.enemyTankList: enemyTank.live: enemyTank.displayTank() enemyTank.randMove() enemyBullet = enemyTank.shot() enemyBullet: MainGame.enemyBulletList.append(enemyBullet) : MainGame.enemyTankList.remove(enemyTank) (): myBullet MainGame.myBulletList: myBullet.live: myBullet.displayBullet() myBullet.move() myBullet.myBullet_hit_enemyTank() : MainGame.myBulletList.remove(myBullet) (): enemyBullet MainGame.enemyBulletList: enemyBullet.live: enemyBullet.displayBullet() enemyBullet.move() enemyBullet.enemyBullet_hit_myTank() : MainGame.enemyBulletList.remove(enemyBullet) (): () () (text): pygame.font.init() font=pygame.font.SysFont() textSurface=font.render(textTEXT_COLOR) textSurface (): eventList= pygame.event.get() event eventList: event.type == pygame.QUIT: .endGame() event.type == pygame.KEYDOWN: event.key == pygame.K_LEFT: MainGame.my_tank.direction=MainGame.my_tank.stop=() event.key == pygame.K_RIGHT: MainGame.my_tank.direction=MainGame.my_tank.stop=() event.key == pygame.K_UP: MainGame.my_tank.direction=MainGame.my_tank.stop=() event.key == pygame.K_DOWN: MainGame.my_tank.direction=MainGame.my_tank.stop=() event.key == pygame.K_SPACE: () (MainGame.myBulletList)<: myBullet = Bullet(MainGame.my_tank) MainGame.myBulletList.append(myBullet) event.type == pygame.KEYUP: event.key==pygame.K_UP event.key==pygame.K_DOWN event.key == pygame.K_LEFT event.key ==pygame.K_RIGHT: MainGame.my_tank.stop = Tank(BaseItem): (lefttop): .images={ :pygame.image.load():pygame.image.load():pygame.image.load():pygame.image.load()} .direction=.image=.images[.direction] .rect=.image.get_rect() .rect.left=left .rect.top=top .speed=.stop=.live=(): .direction == : .rect.left>: .rect.left -= .speed .direction == : .rect.top>: .rect.top -= .speed .direction == : .rect.top+.rect.height<SCREEN_HEIGHT: .rect.top += .speed .direction == : .rect.left+.rect.height<SCREEN_WIDTH: .rect.left += .speed (): Bullet() (): .image=.images[.direction] MainGame.window.blit(.image.rect) MyTank(Tank): (): EnemyTank(Tank): (lefttopspeed): (EnemyTank).(lefttop) .images={ :pygame.image.load():pygame.image.load():pygame.image.load():pygame.image.load() } .direction=.randDirection() .image=.images[.direction] .rect=.image.get_rect() .rect.left=left .rect.top=top .speed=speed .flag=.step=(): num=random.randint() num == : num == : num == : num == : (): .step<=: .direction=.randDirection() .step=: .move() .step-=(): num=random.randint() num<: Bullet() Bullet(BaseItem): (tank): .image=pygame.image.load() .direction=tank.direction .rect=.image.get_rect() .direction == : .rect.left = tank.rect.left + tank.rect.width / - .rect.width / .rect.top = tank.rect.top - .rect.height .direction == : .rect.left = tank.rect.left + tank.rect.width / - .rect.width / .rect.top = tank.rect.top + tank.rect.height .direction == : .rect.left = tank.rect.left - .rect.width / - .rect.width / .rect.top = tank.rect.top + tank.rect.width / - .rect.width / .direction == : .rect.left = tank.rect.left + tank.rect.width .rect.top = tank.rect.top + tank.rect.width / - .rect.width / .speed=.live=(): .direction == : .rect.top>: .rect.top-=.speed : .live=.direction == : .rect.left+.rect.width<SCREEN_WIDTH: .rect.left+=.speed : .live=.direction ==: .rect.top+.rect.height<SCREEN_HEIGHT: .rect.top+=.speed : .live=.direction == : .rect.left>: .rect.left-=.speed : .live=(): MainGame.window.blit(.image.rect) (): enemyTank MainGame.enemyTankList: pygame.sprite.collide_rect(enemyTank): enemyTank.live=.live=explode = Explode(enemyTank) MainGame.explodeList.append(explode) (): MainGame.my_tank MainGame.my_tank.live: pygame.sprite.collide_rect(MainGame.my_tank): explode=Explode(MainGame.my_tank) MainGame.explodeList.append(explode) .live=MainGame.my_tank.live=Wall(): (): (): Explode(): (tank): .rect = tank.rect .images = [ pygame.image.load()pygame.image.load()pygame.image.load()pygame.image.load()pygame.image.load()] .step = .image = .images[.step] .live = (): .step < (.images): .image = .images[.step] .step += MainGame.window.blit(.image.rect) : .live = .step = Music(): (): (): __name__==: MainGame().startGame()
老师,为什么这里提示错误没有这个writerow()方法呀
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637