zoukankan      html  css  js  c++  java
  • 文件批量加密重命名--python脚本AND mysql命令行导入数据库

    在考试中学生交上来的报告,需要进行一下文件名加密,这样阅卷老师就不知道是谁的报告了
    在百度帮助下,完成了加密和解密脚本,

    加密

    #!/usr/bin/python 
    # -*- coding: utf-8 -*-
    
    # coding:utf8
    import os
    import base64
    
    
    def rename():
        i = 0
        path = "D://123"
        path1 = "D://1234"
        filelist = os.listdir(path)  # 该文件夹下所有的文件(包括文件夹)
        for files in filelist:  # 遍历所有文件
            i = i + 1
            Olddir = os.path.join(path, files)  # 原来的文件路径
            #print Olddir
            if os.path.isdir(Olddir):  # 如果是文件夹则跳过
                continue
            filename = os.path.splitext(files)[0]  # 文件名
            #print filename
            filetype = os.path.splitext(files)[1]  # 文件扩展名
            #print filetype
            x=base64.b64encode(str(filename))
            Newdir = os.path.join(path1, x + filetype)  # 新的文件路径
            # x=base64.b64encode(Olddir)
            os.rename(Olddir, Newdir)  # 重命名
    
    
    rename()
    

    解密

    #!/usr/bin/python
    # -*- coding: utf-8 -*-
    
    # coding:utf8
    import os
    import base64
    
    
    def rename():
        i = 0
        path = "D://1234"
        path1 = "D://123"
        filelist = os.listdir(path)  # 该文件夹下所有的文件(包括文件夹)
        for files in filelist:  # 遍历所有文件
            i = i + 1
            Olddir = os.path.join(path, files)  # 原来的文件路径
            #print Olddir
            if os.path.isdir(Olddir):  # 如果是文件夹则跳过
                continue
            filename = os.path.splitext(files)[0]  # 文件名
            #print filename
            filetype = os.path.splitext(files)[1]  # 文件扩展名
            #print filetype
            # x=base64.b64encode(str(filename))
            x = base64.b64decode(str(filename))
            Newdir = os.path.join(path1, x + filetype)  # 新的文件路径
            # x=base64.b64encode(Olddir)
            os.rename(Olddir, Newdir)  # 重命名
    
    
    rename()
    

    记一下用到的命令

    mysql命令行导入数据库

    create database 510cms  //创建数据库510cms
    
    use 510cms              //进入数据库510cms
    source 510cms.sql       //将sql文件导入数据库510cms
    
  • 相关阅读:
    git 撤销更改的文件
    git基于某个分支创建分支
    nodejs 支付宝app支付
    windows提交代码到git仓库
    MongoError: Cannot update '__v' and '__v' at the same time,错误解决办法
    作业3.输入一个年份,判断是闰年还是平年
    作业2.判断一元二次方向根的情况
    求3个数中的最大数
    语句
    运算符
  • 原文地址:https://www.cnblogs.com/hackxf/p/9348662.html
Copyright © 2011-2022 走看看