亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python+pygame實(shí)現(xiàn)坦克大戰(zhàn)小游戲的示例代碼(可以自定義子彈速度)

 更新時(shí)間:2020年08月11日 09:34:47   作者:楊八戒  
這篇文章主要介紹了python+pygame實(shí)現(xiàn)坦克大戰(zhàn)小游戲---可以自定義子彈速度,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
  • python+pygame實(shí)現(xiàn)坦克大戰(zhàn)小游戲—可以自定義子彈速度:
  • 運(yùn)行環(huán)境–python3.7、pycharm;
  • 源碼需要請:點(diǎn)贊留言郵箱;
  • 正常版子彈速度:

普通速度版

加速版子彈速度:

子彈加速版

另外還有多種道具,支持兩人一起玩。main()方法如下:

def main():
  pygame.init()
  pygame.mixer.init()
  resolution = 630, 630
  screen = pygame.display.set_mode(resolution)
  pygame.display.set_caption("Tank Game ")
  # 加載圖片,音樂,音效.
  background_image = pygame.image.load(r"..\image\background.png")
  home_image = pygame.image.load(r"..\image\home.png")
  home_destroyed_image = pygame.image.load(r"..\image\home_destroyed.png")
  bang_sound = pygame.mixer.Sound(r"..\music\bang.wav")
  bang_sound.set_volume(1)
  fire_sound = pygame.mixer.Sound(r"..\music\Gunfire.wav")
  start_sound = pygame.mixer.Sound(r"..\music\start.wav")
  start_sound.play()
  # 定義精靈組:坦克,我方坦克,敵方坦克,敵方子彈
  allTankGroup = pygame.sprite.Group()
  mytankGroup = pygame.sprite.Group()
  allEnemyGroup = pygame.sprite.Group()
  redEnemyGroup = pygame.sprite.Group()
  greenEnemyGroup = pygame.sprite.Group()
  otherEnemyGroup = pygame.sprite.Group() 
  enemyBulletGroup = pygame.sprite.Group()
  # 創(chuàng)建地圖 
  bgMap = wall.Map()
  # 創(chuàng)建食物/道具 但不顯示
  prop = food.Food()
  # 創(chuàng)建我方坦克
  myTank_T1 = myTank.MyTank(1)
  allTankGroup.add(myTank_T1)
  mytankGroup.add(myTank_T1)
  myTank_T2 = myTank.MyTank(2)
  allTankGroup.add(myTank_T2)
  mytankGroup.add(myTank_T2)
  # 創(chuàng)建敵方 坦克
  for i in range(1, 4):
      enemy = enemyTank.EnemyTank(i)
      allTankGroup.add(enemy)
      allEnemyGroup.add(enemy)
      if enemy.isred == True:
        redEnemyGroup.add(enemy)
        continue
      if enemy.kind == 3:
        greenEnemyGroup.add(enemy)
        continue
      otherEnemyGroup.add(enemy)
  # 敵軍坦克出現(xiàn)動(dòng)畫
  appearance_image = pygame.image.load(r"..\image\appear.png").convert_alpha()
  appearance = []
  appearance.append(appearance_image.subsurface(( 0, 0), (48, 48)))
  appearance.append(appearance_image.subsurface((48, 0), (48, 48)))
  appearance.append(appearance_image.subsurface((96, 0), (48, 48)))
  # 自定義事件
  # 創(chuàng)建敵方坦克延遲200
  DELAYEVENT = pygame.constants.USEREVENT
  pygame.time.set_timer(DELAYEVENT, 200)
  # 創(chuàng)建 敵方 子彈延遲1000
  ENEMYBULLETNOTCOOLINGEVENT = pygame.constants.USEREVENT + 1
  pygame.time.set_timer(ENEMYBULLETNOTCOOLINGEVENT, 1000)
  # 創(chuàng)建 我方 子彈延遲200
  MYBULLETNOTCOOLINGEVENT = pygame.constants.USEREVENT + 2
  pygame.time.set_timer(MYBULLETNOTCOOLINGEVENT, 200)
  # 敵方坦克 靜止8000
  NOTMOVEEVENT = pygame.constants.USEREVENT + 3
  pygame.time.set_timer(NOTMOVEEVENT, 8000)
  delay = 100
  moving = 0
  movdir = 0
  moving2 = 0
  movdir2 = 0
  enemyNumber = 3
  enemyCouldMove   = True
  switch_R1_R2_image = True
  homeSurvive     = True
  running_T1     = True
  running_T2     = True
  clock = pygame.time.Clock()
  while True:
    for event in pygame.event.get():
      if event.type == pygame.QUIT:
        pygame.quit()
        sys.exit()
      # 我方子彈冷卻事件
      if event.type == MYBULLETNOTCOOLINGEVENT:
        myTank_T1.bulletNotCooling = True
      # 敵方子彈冷卻事件
      if event.type == ENEMYBULLETNOTCOOLINGEVENT:
        for each in allEnemyGroup:
          each.bulletNotCooling = True
      # 敵方坦克靜止事件
      if event.type == NOTMOVEEVENT:
        enemyCouldMove = True
      # 創(chuàng)建敵方坦克延遲
      if event.type == DELAYEVENT:
        if enemyNumber < 4:
          enemy = enemyTank.EnemyTank()
          if pygame.sprite.spritecollide(enemy, allTankGroup, False, None):
            break
          allEnemyGroup.add(enemy)
          allTankGroup.add(enemy)
          enemyNumber += 1
          if enemy.isred == True:
            redEnemyGroup.add(enemy)
          elif enemy.kind == 3:
            greenEnemyGroup.add(enemy)
          else:
            otherEnemyGroup.add(enemy)
      if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_c and pygame.KMOD_CTRL:
          pygame.quit()
          sys.exit()
        if event.key == pygame.K_e:
          myTank_T1.levelUp()
        if event.key == pygame.K_q:
          myTank_T1.levelDown()
        if event.key == pygame.K_3:
          myTank_T1.levelUp()
          myTank_T1.levelUp()
          myTank_T1.level = 3
        if event.key == pygame.K_2:
          if myTank_T1.speed == 3:
            myTank_T1.speed = 24
          else:
            myTank_T1.speed = 3
        if event.key == pygame.K_1:
          for x, y in [(11,23),(12,23),(13,23),(14,23),(11,24),(14,24),(11,25),(14,25)]:
            bgMap.brick = wall.Brick()
            bgMap.brick.rect.left, bgMap.brick.rect.top = 3 + x * 24, 3 + y * 24
            bgMap.brickGroup.add(bgMap.brick)        
        if event.key == pygame.K_4:
          for x, y in [(11,23),(12,23),(13,23),(14,23),(11,24),(14,24),(11,25),(14,25)]:
            bgMap.iron = wall.Iron()
            bgMap.iron.rect.left, bgMap.iron.rect.top = 3 + x * 24, 3 + y * 24
            bgMap.ironGroup.add(bgMap.iron)        
    # 檢查用戶的鍵盤操作
    key_pressed = pygame.key.get_pressed()
    # 玩家一的移動(dòng)操作
    if moving:
      moving -= 1
      if movdir == 0:
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveUp(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving += 1
        allTankGroup.add(myTank_T1)
        running_T1 = True
      if movdir == 1:
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveDown(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving += 1
        allTankGroup.add(myTank_T1)
        running_T1 = True
      if movdir == 2:
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveLeft(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving += 1
        allTankGroup.add(myTank_T1)
        running_T1 = True
      if movdir == 3:
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveRight(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving += 1
        allTankGroup.add(myTank_T1)
        running_T1 = True
    if not moving:
      if key_pressed[pygame.K_w]:
        moving = 7
        movdir = 0
        running_T1 = True
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveUp(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving = 0
        allTankGroup.add(myTank_T1)
      elif key_pressed[pygame.K_s]:
        moving = 7
        movdir = 1
        running_T1 = True
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveDown(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving = 0
        allTankGroup.add(myTank_T1)
      elif key_pressed[pygame.K_a]:
        moving = 7
        movdir = 2
        running_T1 = True
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveLeft(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving = 0
        allTankGroup.add(myTank_T1)
      elif key_pressed[pygame.K_d]:
        moving = 7
        movdir = 3
        running_T1 = True
        allTankGroup.remove(myTank_T1)
        if myTank_T1.moveRight(allTankGroup, bgMap.brickGroup, bgMap.ironGroup):
          moving = 0
        allTankGroup.add(myTank_T1)
    if key_pressed[pygame.K_j]:
      if not myTank_T1.bullet.life and myTank_T1.bulletNotCooling:
        fire_sound.play()
        myTank_T1.shoot()
        myTank_T1.bulletNotCooling = False
    # 玩家二的移動(dòng)操作
    if moving2:
      moving2 -= 1
      if movdir2 == 0:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveUp(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        running_T2 = True
      if movdir2 == 1:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveDown(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        running_T2 = True
      if movdir2 == 2:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveLeft(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        running_T2 = True
      if movdir2 == 3:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveRight(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        running_T2 = True
    if not moving2:
      if key_pressed[pygame.K_UP]:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveUp(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        moving2 = 7
        movdir2 = 0
        running_T2 = True
      elif key_pressed[pygame.K_DOWN]:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveDown(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        moving2 = 7
        movdir2 = 1
        running_T2 = True
      elif key_pressed[pygame.K_LEFT]:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveLeft(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        moving2 = 7
        movdir2 = 2
        running_T2 = True
      elif key_pressed[pygame.K_RIGHT]:
        allTankGroup.remove(myTank_T2)
        myTank_T2.moveRight(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
        allTankGroup.add(myTank_T2)
        moving2 = 7
        movdir2 = 3
        running_T2 = True
    if key_pressed[pygame.K_KP0]:
      if not myTank_T2.bullet.life:
        # fire_sound.play()
        myTank_T2.shoot()
    
    # 畫背景
    screen.blit(background_image, (0, 0))
    # 畫磚塊
    for each in bgMap.brickGroup:
      screen.blit(each.image, each.rect)    
    # 花石頭
    for each in bgMap.ironGroup:
      screen.blit(each.image, each.rect)    
    # 畫home
    if homeSurvive:
      screen.blit(home_image, (3 + 12 * 24, 3 + 24 * 24))
    else:
      screen.blit(home_destroyed_image, (3 + 12 * 24, 3 + 24 * 24))
    # 畫我方坦克1
    if not (delay % 5):
      switch_R1_R2_image = not switch_R1_R2_image
    if switch_R1_R2_image and running_T1:
      screen.blit(myTank_T1.tank_R0, (myTank_T1.rect.left, myTank_T1.rect.top))
      running_T1 = False
    else:
      screen.blit(myTank_T1.tank_R1, (myTank_T1.rect.left, myTank_T1.rect.top))
    # 畫我方坦克2
    if switch_R1_R2_image and running_T2:
      screen.blit(myTank_T2.tank_R0, (myTank_T2.rect.left, myTank_T2.rect.top))
      running_T2 = False
    else:
      screen.blit(myTank_T2.tank_R1, (myTank_T2.rect.left, myTank_T2.rect.top))  
    # 畫敵方坦克
    for each in allEnemyGroup:
      # 判斷5毛錢特效是否播放      
      if each.flash:
        # 判斷畫左動(dòng)作還是右動(dòng)作
        if switch_R1_R2_image:
          screen.blit(each.tank_R0, (each.rect.left, each.rect.top))
          if enemyCouldMove:
            allTankGroup.remove(each)
            each.move(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
            allTankGroup.add(each)
        else:
          screen.blit(each.tank_R1, (each.rect.left, each.rect.top))
          if enemyCouldMove:
            allTankGroup.remove(each)
            each.move(allTankGroup, bgMap.brickGroup, bgMap.ironGroup)
            allTankGroup.add(each)          
      else:
        # 播放5毛錢特效
        if each.times > 0:
          each.times -= 1
          if each.times <= 10:
            screen.blit(appearance[2], (3 + each.x * 12 * 24, 3))
          elif each.times <= 20:
            screen.blit(appearance[1], (3 + each.x * 12 * 24, 3))
          elif each.times <= 30:
            screen.blit(appearance[0], (3 + each.x * 12 * 24, 3))
          elif each.times <= 40:
            screen.blit(appearance[2], (3 + each.x * 12 * 24, 3))
          elif each.times <= 50:
            screen.blit(appearance[1], (3 + each.x * 12 * 24, 3))
          elif each.times <= 60:
            screen.blit(appearance[0], (3 + each.x * 12 * 24, 3))
          elif each.times <= 70:
            screen.blit(appearance[2], (3 + each.x * 12 * 24, 3))
          elif each.times <= 80:
            screen.blit(appearance[1], (3 + each.x * 12 * 24, 3))
          elif each.times <= 90:
            screen.blit(appearance[0], (3 + each.x * 12 * 24, 3))
        if each.times == 0:
          each.flash = True
    # 繪制我方子彈1
    if myTank_T1.bullet.life:
      myTank_T1.bullet.move()  
      screen.blit(myTank_T1.bullet.bullet, myTank_T1.bullet.rect)
      # 子彈 碰撞 子彈
      for each in enemyBulletGroup:
        if each.life:
          if pygame.sprite.collide_rect(myTank_T1.bullet, each):
            myTank_T1.bullet.life = False
            each.life = False
            pygame.sprite.spritecollide(myTank_T1.bullet, enemyBulletGroup, True, None)
      # 子彈 碰撞 敵方坦克
      if pygame.sprite.spritecollide(myTank_T1.bullet, redEnemyGroup, True, None):
        prop.change()
        bang_sound.play()
        enemyNumber -= 1
        myTank_T1.bullet.life = False
      elif pygame.sprite.spritecollide(myTank_T1.bullet,greenEnemyGroup, False, None):
        for each in greenEnemyGroup:
          if pygame.sprite.collide_rect(myTank_T1.bullet, each):
            if each.life == 1:
              pygame.sprite.spritecollide(myTank_T1.bullet,greenEnemyGroup, True, None)
              bang_sound.play()
              enemyNumber -= 1
            elif each.life == 2:
              each.life -= 1
              each.tank = each.enemy_3_0
            elif each.life == 3:
              each.life -= 1
              each.tank = each.enemy_3_2
        myTank_T1.bullet.life = False
      elif pygame.sprite.spritecollide(myTank_T1.bullet, otherEnemyGroup, True, None):
        bang_sound.play()
        enemyNumber -= 1
        myTank_T1.bullet.life = False  
      #if pygame.sprite.spritecollide(myTank_T1.bullet, allEnemyGroup, True, None):
      #  bang_sound.play()
      #  enemyNumber -= 1
      #  myTank_T1.bullet.life = False
      # 子彈 碰撞 brickGroup
      if pygame.sprite.spritecollide(myTank_T1.bullet, bgMap.brickGroup, True, None):
        myTank_T1.bullet.life = False
        myTank_T1.bullet.rect.left, myTank_T1.bullet.rect.right = 3 + 12 * 24, 3 + 24 * 24
      # 子彈 碰撞 brickGroup
      if myTank_T1.bullet.strong:
        if pygame.sprite.spritecollide(myTank_T1.bullet, bgMap.ironGroup, True, None):
          myTank_T1.bullet.life = False
          myTank_T1.bullet.rect.left, myTank_T1.bullet.rect.right = 3 + 12 * 24, 3 + 24 * 24
      else:  
        if pygame.sprite.spritecollide(myTank_T1.bullet, bgMap.ironGroup, False, None):
          myTank_T1.bullet.life = False
          myTank_T1.bullet.rect.left, myTank_T1.bullet.rect.right = 3 + 12 * 24, 3 + 24 * 24
    # 繪制我方子彈2
    if myTank_T2.bullet.life:
      myTank_T2.bullet.move()  
      screen.blit(myTank_T2.bullet.bullet, myTank_T2.bullet.rect)
      # 子彈 碰撞 敵方坦克
      if pygame.sprite.spritecollide(myTank_T2.bullet, allEnemyGroup, True, None):
        bang_sound.play()
        enemyNumber -= 1
        myTank_T2.bullet.life = False
      # 子彈 碰撞 brickGroup
      if pygame.sprite.spritecollide(myTank_T2.bullet, bgMap.brickGroup, True, None):
        myTank_T2.bullet.life = False
        myTank_T2.bullet.rect.left, myTank_T2.bullet.rect.right = 3 + 12 * 24, 3 + 24 * 24
      # 子彈 碰撞 brickGroup
      if myTank_T2.bullet.strong:
        if pygame.sprite.spritecollide(myTank_T2.bullet, bgMap.ironGroup, True, None):
          myTank_T2.bullet.life = False
          myTank_T2.bullet.rect.left, myTank_T2.bullet.rect.right = 3 + 12 * 24, 3 + 24 * 24
      else:  
        if pygame.sprite.spritecollide(myTank_T2.bullet, bgMap.ironGroup, False, None):
          myTank_T2.bullet.life = False
          myTank_T2.bullet.rect.left, myTank_T2.bullet.rect.right = 3 + 12 * 24, 3 + 24 * 24
    # 繪制敵人子彈
    for each in allEnemyGroup:
      # 如果子彈沒有生命,則賦予子彈生命
      if not each.bullet.life and each.bulletNotCooling and enemyCouldMove:
        enemyBulletGroup.remove(each.bullet)
        each.shoot()
        enemyBulletGroup.add(each.bullet)
        each.bulletNotCooling = False
      # 如果5毛錢特效播放完畢 并且 子彈存活 則繪制敵方子彈
      if each.flash:
        if each.bullet.life:
          # 如果敵人可以移動(dòng)
          if enemyCouldMove:
            each.bullet.move()
          screen.blit(each.bullet.bullet, each.bullet.rect)
          # 子彈 碰撞 我方坦克
          if pygame.sprite.collide_rect(each.bullet, myTank_T1):
            bang_sound.play()
            myTank_T1.rect.left, myTank_T1.rect.top = 3 + 8 * 24, 3 + 24 * 24 
            each.bullet.life = False
            moving = 0 # 重置移動(dòng)控制參數(shù)
            for i in range(myTank_T1.level+1):
              myTank_T1.levelDown()
          if pygame.sprite.collide_rect(each.bullet, myTank_T2):
            bang_sound.play()
            myTank_T2.rect.left, myTank_T2.rect.top = 3 + 16 * 24, 3 + 24 * 24 
            each.bullet.life = False
          # 子彈 碰撞 brickGroup
          if pygame.sprite.spritecollide(each.bullet, bgMap.brickGroup, True, None):
            each.bullet.life = False
          # 子彈 碰撞 ironGroup
          if each.bullet.strong:
            if pygame.sprite.spritecollide(each.bullet, bgMap.ironGroup, True, None):
              each.bullet.life = False
          else:  
            if pygame.sprite.spritecollide(each.bullet, bgMap.ironGroup, False, None):
              each.bullet.life = False
    # 最后畫食物/道具
    if prop.life:
      screen.blit(prop.image, prop.rect)
      # 我方坦克碰撞 食物/道具
      if pygame.sprite.collide_rect(myTank_T1, prop):
        if prop.kind == 1: # 敵人全毀
          for each in allEnemyGroup:
            if pygame.sprite.spritecollide(each, allEnemyGroup, True, None):
              bang_sound.play()
              enemyNumber -= 1
          prop.life = False
        if prop.kind == 2: # 敵人靜止
          enemyCouldMove = False
          prop.life = False
        if prop.kind == 3: # 子彈增強(qiáng)
          myTank_T1.bullet.strong = True
          prop.life = False
        if prop.kind == 4: # 家得到保護(hù)
          for x, y in [(11,23),(12,23),(13,23),(14,23),(11,24),(14,24),(11,25),(14,25)]:
            bgMap.iron = wall.Iron()
            bgMap.iron.rect.left, bgMap.iron.rect.top = 3 + x * 24, 3 + y * 24
            bgMap.ironGroup.add(bgMap.iron)        
          prop.life = False
        if prop.kind == 5: # 坦克無敵
          prop.life = False
          pass
        if prop.kind == 6: # 坦克升級
          myTank_T1.levelUp()
          prop.life = False
        if prop.kind == 7: # 坦克生命+1
          myTank_T1.life += 1
          prop.life = False
           
    # 延遲
    delay -= 1
    if not delay:
      delay = 100  
    pygame.display.flip()
    clock.tick(60)

總結(jié)

到此這篇關(guān)于python+pygame實(shí)現(xiàn)坦克大戰(zhàn)小游戲---可以自定義子彈速度的文章就介紹到這了,更多相關(guān)python+pygame實(shí)現(xiàn)坦克大戰(zhàn)小游戲內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Requests什么的通通爬不了的Python超強(qiáng)反爬蟲方案!

    Requests什么的通通爬不了的Python超強(qiáng)反爬蟲方案!

    今天帶大家學(xué)習(xí)Requests什么的通通爬不了的Python超強(qiáng)反爬蟲方案,文中有非常詳細(xì)的圖文介紹及代碼示例,對正在學(xué)習(xí)python的小伙伴們有很好的幫助,需要的朋友可以參考下
    2021-05-05
  • Python實(shí)現(xiàn)學(xué)生管理系統(tǒng)的完整代碼(面向?qū)ο?

    Python實(shí)現(xiàn)學(xué)生管理系統(tǒng)的完整代碼(面向?qū)ο?

    這篇文章主要介紹了Python實(shí)現(xiàn)學(xué)生管理系統(tǒng)的完整代碼(面向?qū)ο?,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-04-04
  • Python爬蟲之爬取我愛我家二手房數(shù)據(jù)

    Python爬蟲之爬取我愛我家二手房數(shù)據(jù)

    我愛我家的數(shù)據(jù)相對來說抓取難度不大,基本無反爬措施. 但若按照規(guī)則構(gòu)造頁面鏈接進(jìn)行抓取,會(huì)出現(xiàn)部分頁面無法獲取到數(shù)據(jù)的情況.在網(wǎng)上看了幾個(gè)博客,基本上都是較為簡單的獲取數(shù)據(jù),未解決這個(gè)問題,在實(shí)際應(yīng)用中會(huì)出錯(cuò),本文有非常詳細(xì)的代碼示例,需要的朋友可以參考下
    2021-05-05
  • Python3.4實(shí)現(xiàn)遠(yuǎn)程控制電腦開關(guān)機(jī)

    Python3.4實(shí)現(xiàn)遠(yuǎn)程控制電腦開關(guān)機(jī)

    這篇文章主要為大家詳細(xì)介紹了Python3.4實(shí)現(xiàn)遠(yuǎn)程控制電腦開關(guān)機(jī)的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-02-02
  • 使用Python的web.py框架實(shí)現(xiàn)類似Django的ORM查詢的教程

    使用Python的web.py框架實(shí)現(xiàn)類似Django的ORM查詢的教程

    這篇文章主要介紹了使用Python的web.py框架實(shí)現(xiàn)類似Django的ORM查詢的教程,集成的ORM操作數(shù)據(jù)庫向來是Python最強(qiáng)大的功能之一,本文則探討如何在web.py框架上實(shí)現(xiàn),需要的朋友可以參考下
    2015-05-05
  • Python使用pickle模塊存儲(chǔ)數(shù)據(jù)報(bào)錯(cuò)解決示例代碼

    Python使用pickle模塊存儲(chǔ)數(shù)據(jù)報(bào)錯(cuò)解決示例代碼

    這篇文章主要介紹了Python使用pickle模塊存儲(chǔ)數(shù)據(jù)報(bào)錯(cuò)解決示例代碼,小編覺得還是挺不錯(cuò)的,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2018-01-01
  • pandas combine_first函數(shù)處理兩個(gè)數(shù)據(jù)集重疊和缺失

    pandas combine_first函數(shù)處理兩個(gè)數(shù)據(jù)集重疊和缺失

    combine_first是pandas中的一個(gè)函數(shù),它可以將兩個(gè)DataFrame對象按照索引進(jìn)行合并,用一個(gè)對象中的非空值填充另一個(gè)對象中的空值,這個(gè)函數(shù)非常適合處理兩個(gè)數(shù)據(jù)集有部分重疊和缺失的情況,可以實(shí)現(xiàn)數(shù)據(jù)的補(bǔ)全和更新,本文介紹combine_first函數(shù)的語法及一些案例應(yīng)用
    2024-01-01
  • Python Pandas 箱線圖的實(shí)現(xiàn)

    Python Pandas 箱線圖的實(shí)現(xiàn)

    這篇文章主要介紹了Python Pandas 箱線圖的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • 關(guān)于TensorFlow、Keras、Python版本匹配一覽表

    關(guān)于TensorFlow、Keras、Python版本匹配一覽表

    這篇文章主要介紹了關(guān)于TensorFlow、Keras、Python版本匹配一覽表,具有很好的參考價(jià)值,希望對大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-03-03
  • python面積圖之曲線圖的填充

    python面積圖之曲線圖的填充

    這篇文章主要介紹了python面積圖之曲線圖的填充,文章圍繞主題的相關(guān)資料展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下,希望對你的學(xué)習(xí)有所幫助
    2022-06-06

最新評論