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

java.io.FileNotFoundException: D:\游戏. (拒绝访问。)

at java.base/java.io.FileInputStream.open0(Native Method)

at java.base/java.io.FileInputStream.open(FileInputStream.java:213)

at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)

at sn.sxt.复制.TestCopy.copyFile(TestCopy.java:22)

at sn.sxt.复制.TestCopy.main(TestCopy.java:14)




这是代码

package sn.sxt.复制;


import java.io.BufferedInputStream;

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;


public class TestCopy {

public static void main(String[] args) throws IOException {

File srcFile=new File("D:\\游戏.");

File targeFile =new File("D:\\游戏.");

copyFile(srcFile, targeFile);

}

public static void copyFile(File srcFile,File targeFile) throws IOException {

//(1)提高读取效率,从数据源             字节输入流

BufferedInputStream bis = null;

//(2)提高写入效率,写到目的地              字节输出流

BufferedOutputStream bos = null;

try {

bis = new BufferedInputStream(new FileInputStream(srcFile));

bos = new BufferedOutputStream(new FileOutputStream(targeFile));

  

//(3)边读边写

byte[] buf=new byte[1024];   //数组当中中转站

int len=0;             //用于储存数

while((len=bis.read(buf))!=0) {    //把输入的数据存到buf数组中,赋值到len中 。当不等于0时(没有数据)停止

bos.write(buf,0,len);    //添加到bos中 (缓存到buf数组中,从0开始,到循环结束)

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}finally { 

//(5)关闭

try {

if(bos!=null) {

   bos.close();

}if(bis!=null) {

bis.close();

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}


}


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

360截图17430810435033.png

老师,怎么办?

https://blog.csdn.net/Dnison/article/details/82011309

我查找的方法结果还是这样 电脑是w10的 

JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 36198楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 36199楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 36200楼
Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask之Jinja2模版 36202楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 36204楼

"""
简单总结:
1. 有时候我们想要在模版中对一些变量进行处理,那么就必须需要类似于Python中的函数一样,可以将这个值传到函数中,然后做一些操作。
在模版中,过滤器相当于是一个函数,把当前的变量传入到过滤器中,然后过滤器根据自己的功能,再返回相应的值,之后再将结果渲染到页面中。

2. 基本语法:`{{ variable|过滤器名字 }}`。使用管道符号`|`进行组合。
"""
from flask import Flask,render_template

app = Flask(__name__)

# #【1】过滤器的基本使用
# @app.route('/')
# def hello_world():
#     return render_template('index.html',postion=-1)

#【2】default过滤器的基本使用
@app.route('/')
def hello_world():
    context={
        'postion':'-1'
    }
    return render_template('index.html',**context)


if __name__ == '__main__':
    app.run(debug=True)

下面是index

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h3>过滤器的基本使用</h3>
    <p>位置的绝对值为【未使用过滤器】:{{ postion }}</p>
    <p>位置的绝对值为【使用过滤器】:{{ postion|abs }}</p>
    <hr>
    <h3>default过滤器的使用</h3>
    {# 如果取的到就取什么,如果取不到过滤器就会生效 #}
 <p>个性签名【使用过滤器】:{{ signature|default("此人很烂") }}</p>
</body>
</html>

报错:TypeError: bad operand type for abs(): 'str'如下图2019-09-08.png这个是什么意思?类型错误?没添加default时候好使,添加后就报错了。??


Python 全系列/第八阶段:轻量级Web开发利器-Flask框架/Flask之Jinja2模版 36205楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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