【jQuery】js实现文件浏览功能

2023-05-16

1.说明

近期遇到一个浏览用户文件的需求,类似于访问百度网盘那样的列表,包含文件和文件夹,这个功能实现起来很简单,从服务器获取到的文件列表至少要有文件id、父级文件id、是否文件夹这三个字段

2.html设计

前端排版看你实际情况设计,我这里只简单展示文件夹和文件夹以及对应的图表就行,文件时间等其他信息也可以自行展示。我这里使用table标签展示文件列表,每一个文件都是一个tr,效果如下
在这里插入图片描述

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试</title>
    <script src="http://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
</head>
<style>
    #explorerContainer {
        width: 800px;
        margin: 0 auto;
        /* display: none; */
    }

    .fileIco {
        width: 32px;
        height: 32px;
    }

    .fileRow {
        width: 550px;
        border-bottom: 1px solid #a75318;
        line-height: 50px;
        align-items: center;
        padding: 0 20px;
        margin-left: 110px;
    }

    .fileRow span {
        height: 32px;
        line-height: 32px;
    }

    .fileRow span {
        margin: 0 10px;
    }

    .fileRow span a {
        color: #582a0a;
    }
</style>

<body>
    <div id="explorerContainer">
        <table>
            <tbody>
                <tr>
                    <td>
                        <div class="fileRow">
                            <span><a href="" id="upperLevel">上一级...</a></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fileRow">
                            <img src="folder.png" alt="" class="fileIco">
                            <span><a href="">新建文件夹1</a></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fileRow">
                            <img src="folder.png" alt="" class="fileIco">
                            <span><a href="javascript:void(0);">新建文件夹2</a></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fileRow">
                            <img src="exe.png" alt="" class="fileIco">
                            <span><a href="">测试文件.exe</a></span>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>

</html>

3.展示文件列表

样式设置好之后,我们先试着展示固定的文件,文件保存在一个数组中,每一个文件都有文件id,我这里使用文件路径代替,只要是唯一的就行,所以这里的每一个文件对象都有path、parent_path、isdir这三个属性,分别表示文件路径、父级文件路径、是否文件夹

let upperLevelPath = ""
let files = [
    {
        "category": 6,
        "fs_id": 934435682367559,
        "isdir": 1,
        "local_ctime": 1621308615,
        "local_mtime": 1621308615,
        "path": "/sharelink0-480654963977751/3dsmax/3dmax2022",
        "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
        "server_ctime": 1621308615,
        "server_filename": "3dmax2022",
        "server_mtime": 1644238064,
        "size": 0
    },
    {
        "category": 5,
        "fs_id": 517879331580918,
        "isdir": 0,
        "local_ctime": 1521869688,
        "local_mtime": 1521869688,
        "md5": "2a5f6be1bbc6d24fc172e887ed424604",
        "path": "/sharelink3073240792-480654963977751/3dsmax/Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_001_003.sfx.exe",
        "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
        "server_ctime": 1521869688,
        "server_filename": "Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_001_003.sfx.exe",
        "server_mtime": 1561784982,
        "size": 2115408424
    },
    ...
]

再写一个函数遍历files文件数组,拼凑DOM展示,不过要注意“上一级”按钮要特别处理,虽然它应该具有文件夹的功能,但是它是一个特殊的文件夹

let upperLevelPath = ""
function showFiles(tempList, parent_path) {
    let tbody = $('<tbody><tr><td> <div class="fileRow"><span><a href="javascript:void(0);" path="' + upperLevelPath + '" id="upperLevel">上一级...</a></span></div></td></tr></tbody>')
    for (var i = 0, len = tempList.length; i < len; i++) {
        if (tempList[i].parent_path == parent_path) {
            let img = $('<img alt="" class="fileIco">')
            if (tempList[i].isdir == 1) {
                img.attr("src", 'folder.png')
            } else {
                img.attr("src", "exe.png")
            }
            let span = $('<span><a href="javascript:void(0);" path="' + tempList[i].path + '" parent_path="' + tempList[i].parent_path + '" is_dir=' + tempList[i].isdir + ' fs_id=' + tempList[i].fs_id + ' >' + tempList[i].server_filename + '</a></span>')
            let fileRowDiv = $('<div class="fileRow"></div>')
            fileRowDiv.append(img)
            fileRowDiv.append(span)
            if (tempList[i].isdir == 0) {
                fileRowDiv.append($('<div id="rlink_div_' + tempList[i].fs_id + '"></div>'))
            }
            tbody.append($('<tr><td>' + fileRowDiv[0].outerHTML + '</td></tr>'))
        }
    }
    $('tbody').empty()
    $('tbody').append(tbody)

}

showFiles(files, "/sharelink3073240792-480654963977751/3dsmax")

再来看一下效果
在这里插入图片描述

4.浏览文件

文件列表可以从服务器获取,获取之后调用showFiles()进行出来,但还不具备点击功能,比如说点击文件夹应该展示该文件夹里的文件。当点击进入某个文件夹的时候记录一下它的父级路径,保存到“上一级”按钮,当要返回上一级的时候就很方便了,但是,如果还要再上一级,这时候就没办法了,不过,只能获取子文件的上级然后在文件列表里找到父级的父级,不用担心上级文件夹为空,因为能连进两级,那父级不必不为空。当点击了文件或文件夹,如果在文件列表里找不到它的子集了,这时候可以发起从服务器获取的请求,当然,应该先判断一下是否已经存在文件列表了,如果已经存在就不需要再次发起请求。
所以监听点击文件的方法也很容易写出来

function monitorFileClick() {
    $('.fileRow span a').click(function () {
        let path = $(this).attr("path")
        let id_ = $(this).attr("id")

        if (id_ == "upperLevel") {
            if (!upperLevelPath) {
                lastPath = $(".fileRow span a").last().attr("parent_path")
                console.log('lastPath:', lastPath)
                if (!lastPath) {
                    alert("没有上一级了哦")
                    return
                }
                for (var i = files.length - 1; i >= 0; i--) {
                    if (files[i].path == lastPath && files[i].parent_path) {
                        upperLevelPath = files[i].parent_path
                        break
                    }
                }
                if (!upperLevelPath) {
                    alert("没有上一级了啦啦啦啦啦")
                    return
                }
            }
            showFiles(files, upperLevelPath)
            upperLevelPath = ""
        } else {
            if ($(this).attr('is_dir') == 1) {
                let isIn = isInTempList(files, path)
                if (!isIn) {
                    alert("点击了文件夹,发起请求")
                }
                if ($(this).attr("parent_path")) {
                    upperLevelPath = $(this).attr("parent_path")
                }
                showFiles(files, path)
            } else {
                console.log("这不是文件夹")
                if ($(this).attr("isSuccess") == 1) {
                    return
                }
                alert("请求文件")
            }
        }
    })
}

function isInTempList(tempList, path) {
    console.log("isInTempList()", tempList.length, path)
    for (var i = 0, len = tempList.length; i < len; i++) {
        if (tempList[i].parent_path == path) {
            return true
        }
    }
    return false
}

什么时候调用这个方法呢?当然是展示完列表就调用

function showFiles(tempList, parent_path) {
    ...
    $('tbody').empty()
    $('tbody').append(tbody)

    monitorFileClick()
}

5.完整代码

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试</title>
    <script src="http://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
</head>
<style>
    #explorerContainer {
        width: 800px;
        margin: 0 auto;
        /* display: none; */
    }

    .fileIco {
        width: 32px;
        height: 32px;
    }

    .fileRow {
        width: 550px;
        border-bottom: 1px solid #a75318;
        line-height: 50px;
        align-items: center;
        padding: 0 20px;
        margin-left: 110px;
    }

    .fileRow span {
        height: 32px;
        line-height: 32px;
    }

    .fileRow span {
        margin: 0 10px;
    }

    .fileRow span a {
        color: #582a0a;
    }
</style>

<body>
    <div id="explorerContainer">
        <table>
            <tbody>
                <tr>
                    <td>
                        <div class="fileRow">
                            <span><a href="" id="upperLevel">上一级...</a></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fileRow">
                            <img src="folder.png" alt="" class="fileIco">
                            <span><a href="">新建文件夹1</a></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fileRow">
                            <img src="folder.png" alt="" class="fileIco">
                            <span><a href="javascript:void(0);">新建文件夹2</a></span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div class="fileRow">
                            <img src="exe.png" alt="" class="fileIco">
                            <span><a href="">测试文件.exe</a></span>
                        </div>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
<script>
    let upperLevelPath = ""
    let files = [
        {
            "category": 6,
            "fs_id": 934435682367559,
            "isdir": 1,
            "local_ctime": 1621308615,
            "local_mtime": 1621308615,
            "path": "/sharelink0-480654963977751/3dsmax/3dmax2022",
            "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
            "server_ctime": 1621308615,
            "server_filename": "3dmax2022",
            "server_mtime": 1644238064,
            "size": 0
        },
        {
            "category": 5,
            "fs_id": 830937815955136,
            "isdir": 0,
            "local_ctime": 1521869699,
            "local_mtime": 1521869699,
            "md5": "a79f60762a81dba8fd806233e9941900",
            "path": "/sharelink3073240792-480654963977751/3dsmax/Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_003_003.sfx.exe",
            "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
            "server_ctime": 1521869699,
            "server_filename": "Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_003_003.sfx.exe",
            "server_mtime": 1561784982,
            "size": 450021000
        },
        {
            "category": 5,
            "fs_id": 92781334838182,
            "isdir": 0,
            "local_ctime": 1521869691,
            "local_mtime": 1521869691,
            "md5": "4de7ffe1ca87511b599aa60a0bce4a24",
            "path": "/sharelink3073240792-480654963977751/3dsmax/Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_002_003.sfx.exe",
            "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
            "server_ctime": 1521869691,
            "server_filename": "Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_002_003.sfx.exe",
            "server_mtime": 1561784982,
            "size": 2115408424
        },
        {
            "category": 5,
            "fs_id": 517879331580918,
            "isdir": 0,
            "local_ctime": 1521869688,
            "local_mtime": 1521869688,
            "md5": "2a5f6be1bbc6d24fc172e887ed424604",
            "path": "/sharelink3073240792-480654963977751/3dsmax/Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_001_003.sfx.exe",
            "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
            "server_ctime": 1521869688,
            "server_filename": "Autodesk_3ds_Max_2019_EFGJKPS_Win_64bit_001_003.sfx.exe",
            "server_mtime": 1561784982,
            "size": 2115408424
        },
        {
            "category": 6,
            "fs_id": 381680330545337,
            "isdir": 0,
            "local_ctime": 1561785049,
            "local_mtime": 1561785036,
            "md5": "9afb7d34ac26ead6b7435421c7bd5014",
            "path": "/sharelink3073240792-480654963977751/3dsmax/3dsmax2019zhuceji.zip",
            "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
            "server_ctime": 1561785049,
            "server_filename": "3dsmax2019zhuceji.zip",
            "server_mtime": 1561785049,
            "size": 2044074
        },
        {
            "category": 6,
            "fs_id": 934435682367559,
            "isdir": 1,
            "local_ctime": 1621308615,
            "local_mtime": 1621308615,
            "path": "/sharelink0-480654963977751/3dsmax/test",
            "parent_path": "/sharelink0-480654963977751/3dsmax/3dmax2022",
            "server_ctime": 1621308615,
            "server_filename": "test",
            "server_mtime": 1644238064,
            "size": 0
        },
        {
            "category": 6,
            "fs_id": 934435682367559,
            "isdir": 1,
            "local_ctime": 1621308615,
            "local_mtime": 1621308615,
            "path": "/sharelink0-480654963977751/3dsmax/3dmax2023",
            "parent_path": "/sharelink3073240792-480654963977751/3dsmax",
            "server_ctime": 1621308615,
            "server_filename": "3dmax2023",
            "server_mtime": 1644238064,
            "size": 0
        },
        {
            "category": 6,
            "fs_id": 934435682367559,
            "isdir": 0,
            "local_ctime": 1621308615,
            "local_mtime": 1621308615,
            "path": "/sharelink0-480654963977751/3dsmax/3dmax2023/test",
            "parent_path": "/sharelink0-480654963977751/3dsmax/3dmax2023",
            "server_ctime": 1621308615,
            "server_filename": "3dmax2023test",
            "server_mtime": 1644238064,
            "size": 0
        },

    ]

    function showFiles(tempList, parent_path) {
        let tbody = $('<tbody><tr><td> <div class="fileRow"><span><a href="javascript:void(0);" path="' + upperLevelPath + '" id="upperLevel">上一级...</a></span></div></td></tr></tbody>')
        for (var i = 0, len = tempList.length; i < len; i++) {
            if (tempList[i].parent_path == parent_path) {
                let img = $('<img alt="" class="fileIco">')
                if (tempList[i].isdir == 1) {
                    img.attr("src", 'folder.png')
                } else {
                    img.attr("src", "exe.png")
                }
                let span = $('<span><a href="javascript:void(0);" path="' + tempList[i].path + '" parent_path="' + tempList[i].parent_path + '" is_dir=' + tempList[i].isdir + ' fs_id=' + tempList[i].fs_id + ' >' + tempList[i].server_filename + '</a></span>')
                let fileRowDiv = $('<div class="fileRow"></div>')
                fileRowDiv.append(img)
                fileRowDiv.append(span)
                if (tempList[i].isdir == 0) {
                    fileRowDiv.append($('<div id="rlink_div_' + tempList[i].fs_id + '"></div>'))
                }
                tbody.append($('<tr><td>' + fileRowDiv[0].outerHTML + '</td></tr>'))
            }
        }
        $('tbody').empty()
        $('tbody').append(tbody)

        monitorFileClick()

    }
    function isInTempList(tempList, path) {
        console.log("isInTempList()", tempList.length, path)
        for (var i = 0, len = tempList.length; i < len; i++) {
            if (tempList[i].parent_path == path) {
                return true
            }
        }
        return false
    }

    showFiles(files, "/sharelink3073240792-480654963977751/3dsmax")

    function monitorFileClick() {
        $('.fileRow span a').click(function () {
            let path = $(this).attr("path")
            let id_ = $(this).attr("id")

            if (id_ == "upperLevel") {
                if (!upperLevelPath) {
                    lastPath = $(".fileRow span a").last().attr("parent_path")
                    console.log('lastPath:', lastPath)
                    if (!lastPath) {
                        alert("没有上一级了哦")
                        return
                    }
                    for (var i = files.length - 1; i >= 0; i--) {
                        if (files[i].path == lastPath && files[i].parent_path) {
                            upperLevelPath = files[i].parent_path
                            break
                        }
                    }
                    if (!upperLevelPath) {
                        alert("没有上一级了啦啦啦啦啦")
                        return
                    }
                }
                showFiles(files, upperLevelPath)
                upperLevelPath = ""
            } else {
                if ($(this).attr('is_dir') == 1) {
                    let isIn = isInTempList(files, path)
                    if (!isIn) {
                        alert("点击了文件夹,发起请求")
                    }
                    if ($(this).attr("parent_path")) {
                        upperLevelPath = $(this).attr("parent_path")
                    }
                    showFiles(files, path)
                } else {
                    console.log("这不是文件夹")
                    if ($(this).attr("isSuccess") == 1) {
                        return
                    }
                    alert("请求文件")
                }
            }
        })
    }
</script>

</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【jQuery】js实现文件浏览功能 的相关文章

  • EFR32FG14 UART的使用方法

    EFR32FG14 UART的使用方法 1 初始化串口 xff08 PA0 gt TX PA1 gt RX xff09 span class token keyword void span span class token function
  • EFR32解锁方法

    EFR32锁住的解锁方法 在某些情况下 xff0c 芯片可能会被锁住 xff0c 导致J LINK等工具连接不上 xff0c 可以参考如下方法 xff1a 1 进入commander exe所在的目录 xff1b 按住Shift 43 右键
  • TFT1.44寸屏ST7735S屏幕使用-stm32f103c8t6

    TFT1 44寸屏ST7735S屏幕使用 stm32f103c8t6 K xff1a 背景灯 RESET xff1a tft复位 RS xff1a 控制线 xff08 数据或者命令 xff09 SDA xff1a 数据线 xff08 SPI
  • 8421拨码器 R7H3-16 的使用

    8421拨码器 R7H3 16 的使用 使用方法极其简单 xff0c 1 2 4 8脚分解与单片机的4个IO脚连接 xff0c IO配置为输入即可 0代表低电平 xff0c 1代表高电平 档位 脚位124801111101112101130
  • Ubuntu 18 上不了网解决方法

    Ubuntu 18 出现网络异常 1 打开命令行 Ctrl 43 Alt 43 t 2 关闭网络 sudo service network manager stop 3 删除网络 sudo rm var lib NetworkManager
  • GPIO引脚 模拟 IIC(软件IIC)

    GPIO引脚 模拟 IIC 软件IIC IIC总线在传输数据的过程中一共有三种类型信号 xff0c 分别为 xff1a 开始信号 结束信号和应答信号 IIC总线的时序图 xff1a 空闲状态 当IIC总线的数据线SDA和时钟线SCL两条信号
  • ESP32/ESP8266 MQTT协议接入阿里云(一)

    ESP32 ESP8266 MQTT协议接入阿里云 xff08 一 xff09 1 搭建阿里云环境 xff08 1 xff09 跳转连接 xff1a https iot console aliyun com lk summary new x
  • ESP32/ESP8266 MQTT协议接入阿里云(二)

    ESP32 ESP8266 MQTT协议接入阿里云 xff08 二 xff09 1 在连接阿里云之前 xff0c 需要先了解MQTT的连接协议 CONNECT 协议格式 xff1a 固定包头 43 可变包头 43 有效载体 xff08 1
  • https是如何验证证书的有效性的

    证书验证的过程是使用非对称加密的 xff0c 客户端对服务器端发起请求 xff0c 服务器返回一个证书 xff0c 客户端验证这个证书的合法性 xff0c 如果这个证书是合法的 xff0c 那么就生成一个随机值 xff0c 利用这个随机值作
  • Kali Linux 更新源

    vi etc apt source list 添加下列更新源 中科大 deb http mirrors ustc edu cn kali kali rolling main non free contrib deb src http mir
  • 安装所有Kali 工具包

    apt get kali linux all
  • 路由选路三原则

    路由选路的三原则 最长掩码匹配原则AD值 Administrative Distance 通告距离 路由类型AD值Connect0Static1EIGRP Summary5EBGP20EIGRP 内部90OSPF110RIP120EIGRP
  • OSPF7种状态

  • CentOS 7 由原来的root@localhost~# 变成了-bash-4.2#

    发生这种原因可能是 root 目录下缺少了几个配置 bashrc 和 bash profile 进入 etc skel 目录下 将 bashrc 和 bash profile复制到 root 目录下 1 cp etc skel bashrc
  • Kali 中 dnsdict6 安装过程

    更新下载源 文件目录 etc apt source list 增加源deb http mirrors ustc edu cn kali kali rolling main non free contrib deb src http mirr
  • 在CentOS 7上搭建代理服务器(Socks 5)

    安装环境配置 1 yum install gcc 2 yum install openldap devel 3 yum install pam devel 4 yum install openssl devel 安装Socks 5 wget
  • Archlinux 安装教程 - 附详细图文(一)

    博主声明 xff1a 转载请在开头附加本文链接及作者信息 xff0c 并标记为转载 本文由博主 威威喵 原创 xff0c 请多支持与指教 本文首发于此 博主 xff1a 威威喵 博客主页 xff1a https blog csdn net
  • C语言实战——生产者消费者问题

    C语言实战 生产者消费者问题 方法摘要 生产者消费者共享缓冲区 xff0c 生产者向缓冲区中放数据 xff0c 消费者从缓冲取中取数据 xff0c 当缓冲区中被放满时 xff0c 生产者进程就必须进入挂起状态 xff0c 直到消费者从缓冲中
  • archlinux/manjaro 安装wps-office

    安装 需要添加AUR库并且安装好yay span class token function sudo span pacman s yay 从AUR安装 yay S wps office mui zh cn wps office mime c
  • 学C++就学服务端,先把apue和unp两卷看了,接着libevent,出来找工作应该没问题

    学C 43 43 就学服务端 xff0c 先把apue和unp两卷看了 xff0c 接着libevent xff0c 出来找工作应该没问题

随机推荐

  • 【2022小米秋招(2023校招)】软件开发方向 笔试题1——链表反转

    题目 xff1a 给你单链表的头指针 head 和两个整数 left 和 right xff0c 其中 left lt 61 right 请你反转从位置 left 到位置 right 的链表节点 xff0c 返回反转后的链表 输入描述 xf
  • c++17实现同步阻塞队列

    话不多说 xff0c 上代码 xff1a pragma once include lt condition variable gt include lt deque gt include lt mutex gt include lt sha
  • 【系统】VMware虚拟机安装Windows11

    去年微软推出了Windows11操作系统 xff0c 但由于新系统BUG多或者纯属更喜欢win10等原因 xff0c 很多同学都跟冰冰一样依旧不选择升级 xff0c 但有些情况又需要使用win11 xff0c 比如说使用某些软件或者做测试等
  • 【js】点击让窗口抖动动画效果

    比如说用户的未输入密码就点击登录按钮 xff0c 则输入框会晃动一下提示用户需要输入 xff0c 实现这种效果很简单 xff0c 只需要给元素添加一个类 xff0c 然后做一个关键帧动画即可 css代码 span class token s
  • 【unity 】第一人称角色控制器手机虚拟双摇杆

    1 说明 第一人称角色控制器很常见 xff0c unity的标准资源包里也有 xff0c 但试了一下 xff0c 那个好像只有摇杆移动方向 xff0c 无法使用摇杆进行视角旋转 xff0c 所以我这里还是自己动手实现一个吧 制作两个虚拟摇杆
  • 【python】多线程下载m3u8分段视频

    1 说明 m3u8是一种传输数据的方式 xff0c 比如说一集20分钟的完整视频被分割成一千多段一两秒的小视频 xff0c 客户端播放的时候是感觉是连续 xff0c 但如果你要下载这集视频 xff0c 那就要把一千多个小视频全都下载然后自己
  • 【小程序】微信小程序重复循环平移动画

    1 说明 需求是让一张图片不断重复地从下往上移动 xff0c 实现方法由多种 xff0c wx createAnimation 关键帧动画 swiper等都能实现 2 wx createAnimation 最先想到的是使用wx create
  • 【mysql】视图的创建、修改、删除、查看所有视图、不能修改视图的情况

    1 视图 视图类似于表 xff0c 但不是真实存在的表 xff0c 而是根据已存在的表创建出来的虚拟表 xff0c 即它并不会被保存在物理磁盘上 视图的使用场景很多 xff0c 比如说 xff0c 你需要给某个用户提供某张表的访问权限 xf
  • 【django】django-redis的使用方法

    1 说明 redis作为一个缓存数据库 xff0c 在各方面都有很大作用 xff0c Python支持操作redis xff0c 如果你使用Django xff0c 有一个专为Django搭配的redis库 xff0c 即django re
  • 【Linux】Linux镜像源地址换成国内源

    1 说明 像Ubuntu kali等比较受欢迎的Linux发行版 xff0c 因为都是国外的 xff0c 所以默认的源也是国外的 xff0c 在国内访问会比较慢 xff08 得不行 xff09 xff0c 所以建议换成国内源吧 xff0c
  • 04一篇彻底理解 指针常量和常量指针 指向常量的常指针

    1 在汉语中 xff0c 定语一般都放在中心词的前面 xff0c 像C语言和C 43 43 语言这种技术性语言 xff0c 更是如此 所以定语重要还是中心词重要 xff0c 肯定是中心词重要 如 xff1a 美丽的女孩 美丽的是定语 女孩是
  • 【python】常用pycryptodome完成RSA非对称加密解密、签名验签

    1 安装pycryptodome 安装pycryptodome pip install pycryptodome 2 生成随机公私钥 生成公私钥 xff0c 并且导出为PEM格式 xff0c 保存问文件 span class token k
  • 【系统】查看文件的md5值

    查看md5可以确认文件是否被篡改或者是否下载完成 xff0c 网上有很多小工具 xff0c 但实际上系统自带的命令也能查看 1 Windows系统 Windows系统自带有certutil命令里面包含了查看文件哈希的命令 xff0c 可以在
  • 【Python】Python图形化界面库PySimpleGUI的简单使用

    1 说明 能实现Python的图形化界面的库挺多的 xff0c 比较出名的可能是tkinter PyQt等 xff0c 但它们都不够快速 xff0c PySimpleGUI就是一个可以让我们快速创建图形界面的库 xff0c 它整合了 tki
  • 【Python】使用requests库实现多线程下载大文件

    1 说明 使用requests库可以实现网络请求 xff0c 但如果用于下载大文件 xff0c 单线程下载确实不能很好地利用宽带 xff0c 改为多线程会更好一点 2 实现思路 1 当我们请求下载文件的时候 xff0c 可以使用head请求
  • 【Python】占位符格式化输出

    1 说明 Python的格式化输出有好几种方式 xff0c 比较常用的是 格式化 format 方法以及3 6版本支持的f string xff0c 这三种格式化的用法这里不讲 xff0c 这里主要讲一下控制占位符的格式 xff0c 比如说
  • 【Python】asyncio的使用(async、await关键字)

    1 协程 相比于线程和进程 xff0c 协程显得更加轻量级 xff0c 因为它是在函数直接进行切换 xff0c 所以开销更小 xff0c 也更灵活 之前有介绍过greenlet gevent这样的协程库 xff08 python 协程 xf
  • 【Python】pysimplegui主动事件(多线程执行耗时任务解决主线程卡死问题)

    1 说明 PySimpleGui是一个免费开源的Python GUI库 xff0c 用起来比Tkinter PyQt5等库更简单 xff0c 所以可以用来快速开发GUI程序 xff0c 高效便捷 关于PySimpleGUI的基本使用 xff
  • 【Python】使用pyinstaller打包Python程序为EXE可执行程序

    1 说明 我们写出来的Python代码需要配合解释器才能执行 xff0c 并不能像C Java等语言一样编译成可执行程序 xff0c 所以在没有安装Python环境的电脑上就不方便运行py代码 xff0c 为了解决这个问题 xff0c 我们
  • 【jQuery】js实现文件浏览功能

    1 说明 近期遇到一个浏览用户文件的需求 xff0c 类似于访问百度网盘那样的列表 xff0c 包含文件和文件夹 xff0c 这个功能实现起来很简单 xff0c 从服务器获取到的文件列表至少要有文件id 父级文件id 是否文件夹这三个字段