会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132365个问题
JAVA 全系列/(旧的隐藏)第十一阶段:spring全家桶(Spring Boot)/Spring Boot 37696楼

mubatisdemo.zip

image.png

老师 这个代码报错这样 你看下哪里有问题

JAVA 全系列/第六阶段:项目管理与SSM框架/Mybatis 37697楼
Python 全系列/第一阶段:Python入门/编程基本概念 37698楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 37699楼
JAVA 全系列/第四阶段:网页编程和设计/Javascript 语言(旧) 37700楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/手写服务器项目(旧) 37703楼
JAVA 全系列/第三阶段:数据库编程/MySQL数据库的使用 37704楼
Python 全系列/下架-第十二阶段:Python_大型电商项目(5天后下架)/Django项目阶段-电商项目(旧) 37706楼

老师,我这个为啥会报错呢,写数据和读数据顺序都是对应的呀

代码:

import java.io.*;
import java.util.Date;

/**
 * @author LLLYF
 *
 */
public class Test3 {
    public static void main(String[] args) throws IOException {
        //write();
          read();

    }
    //读取数据的方法
    public static void read() throws IOException {
        //(1)数据源
        FileInputStream fis=new FileInputStream("E:\\date.txt");
        //(2)提高读取效率
        BufferedInputStream bis=new BufferedInputStream(fis);
        //(3)处理java的基本数据类型和字符串
        DataInputStream dis=new DataInputStream(bis);
        //(4)读数据--(读数据的顺序要与写数据的顺序完全一致)
        System.out.println(dis.readInt());
        System.out.println(dis.readDouble());
        System.out.println(dis.readBoolean());
        System.out.println(dis.readChar());
        System.out.println(dis.readUTF());
        //关闭
        dis.close();
    }
    public static void write() throws IOException {
        //(1)目的地
        FileOutputStream fos=new FileOutputStream("E:\\date.txt");
        //(2)缓冲流提高写入效率
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        //(3)数据流,增加对java基本数据类型和String的处理
        DataOutputStream dos=new DataOutputStream(bos);
        //(4)写入数据
        dos.writeInt(98);
        dos.writeDouble(98.5);
        dos.writeBoolean(true);
        dos.writeChar('a');
        dos.writeUTF("helloworld");
        //(5)关闭流
        if(dos!=null){
                    dos.close();
        }
    }

}

运行结果:

T9}OMCY0DGRIB}ZAJMNTHBR.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 37707楼

#导入模块
import pygame

SCREEN_WIDTH = 700   # 高度700像素
SCREEN_HEIGHT = 500  # 宽度500像素
BG_COLOR = pygame.Color(0, 0, 0)
TEXT_COLOR = pygame.Color(255,0,0)

class MainGame():
    window = None
    my_tank = None
    def __init__(self):
        pass
    # 开始游戏
    def startGame(self):
        # 加载主窗口
        # 初始化窗口
        pygame.display.init()
        # 设置窗口的大小和显示
        # 设置窗口标题
        MainGame.window = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT])
        # 初始化我方坦克
        MainGame.my_tank = Tank(350, 250)

        # 设置窗口标题
        pygame.display.set_caption('坦克大战1.03,世界末日')
        while True:
            # 给窗口填充颜色
            MainGame.window.fill(BG_COLOR)
            # 获取事件
            self.getEvent()
            # 绘制文字
            MainGame.window.blit(self.gettextsuface('敌方坦克剩余数量%d'%6),(10,10))
            # 调用坦克显示的方法
            MainGame.my_tank.displayTank()
            pygame.display.update()

    # 结束游戏
    def endGame(self):
        print('谢谢使用,欢迎再来')
        exit()
    #左上角文字绘制
    def gettextsuface(self,text):
        # 初始化字体
        pygame.font.init()
        # 获取字体font对象
        font = pygame.font.SysFont('kaiti',18)
        # 绘制文字信息
        textSuface = font.render(text,True,TEXT_COLOR)
        return textSuface
    # 获取事件
    def getEvent(self):
        # 获取所有事件
        eventlist = pygame.event.get()
        # 遍历事件
        for event in eventlist:
            # 判断按下的键是关闭还是按下键盘
            # 如果按下的是退出 关闭窗口
            if event.type == pygame.QUIT:
                self.endGame()
            # 如果按下的是键盘,判断按下的是上,下,左, 右
            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():
    # 添加距离左边left 距离上边top
    def __init__(self, left, top):
        # 保存加载的图片
        self.images = {
            'U': pygame.image.load('img/p1tankU.gif'),
            'D': pygame.image.load('img/p1tankD.gif'),
            'L': pygame.image.load('img/p1tankL.gif'),
            'R': pygame.image.load('img/p1tankR.gif')
        }
        # 方向
        self.direction = 'U'
        # 根据当前图片的方向获取图片  surface
        self.image = self.images[self.direction]
        # 根据图片获取区域
        self.rect = self.image.get_rect()
        # 设置区域的left和TOP
        self.rect.left = left
        self.rect.top = top

    #移动
    def move(self):
        pass

    #射击
    def shot(self):
        pass

    #展示坦克的方法
    def displayTank(self):
        # 获取展示的对象
        self.image = self.images[self.direction]
        # 调用blit方法展示
        MainGame.window.blit(self.image, self.rect)

# 我方坦克
class MyTank(Tank):
    def __init__(self):
        pass

# 敌方坦克
class EnemyTank(Tank):
    def __init__(self):
        pass

# 子弹类
class Bullet():
    def __init__(self):
        pass

    #展示子弹
    def displayBullet(self):
        pass

    #移动
    def move(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().startGame()
    # MainGame().gettextsuface()
    
    
    Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "C:\Users\安德虎\PycharmProjects\gui\tanke01.py", line 179, in <module>
    MainGame().startGame()
  File "C:\Users\安德虎\PycharmProjects\gui\tanke01.py", line 46, in startGame
    MainGame.my_tank = Tank(350, 250)
  File "C:\Users\安德虎\PycharmProjects\gui\tanke01.py", line 99, in __init__
    'u': pygame.image.load('img/p1tankU.gif'),
FileNotFoundError: No file 'img/p1tankU.gif' found in working directory 'C:\Users\安德虎\PycharmProjects\gui'.


Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 37708楼

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>106.window对象的name属性</title>
</head>
<body>
    <button>跨域传输</button>
<script>
   
    //console.log(num);
    //如果想要获取一个页面内的信息,那么必须先加载
    var but= document.querySelector('button');
    but.onclick=function(){
        var iframe= document.createElement('iframe');
        iframe.src='106中的page.html';//加载保存了信息的页面
        iframe.style.display='none';  //加载过来不显示
        document.body.appendChild(iframe);
        //当iframe加载完毕,意味着window.name的内容已经被赋予完毕
        iframe.onload=function(eve){
            var iframeWindowName=eve.target.contentWindow.name;
            console.log( iframeWindowName);
            console.log(typeof iframeWindowName);
            eval(iframeWindowName);  //解析字符串
            console.log(num);
        }
    }  
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    var num=10;
    window.name='var num=10;';
    window.name='var num=[1,2,3];'; //可以是数组
    window.name='var num={age:22};';//对象也可以
    
</script>
</body>
</html>

微信图片_20200512190140.jpg

老师我按视频中的代码敲的,为啥会出现这种结果,这是什么情况,浏览器的版本不同吗???

WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 37709楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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