栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python批量修改xshell保存的密码

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python批量修改xshell保存的密码

python批量修改xshell保存的密码

下面的脚本会在标签目录下生成out文件夹,将新标签保存进去。

import os
curr_pwd= "Password=*****==" #找到xsh保存的路径下打开现有的文件查看密码
update_pwd = "Password=******==n"
path = input('请输入xsh文件路径:')  #输入xsh保存的路径

for root, dirs, files in os.walk(path):
    for f1 in files:
        if '.xsh' in f1:   #判断为xsh文件
            with open(path +'\'+ f1,encoding='utf-16') as f:  #xsh文件编码为utf16
                if not os.path.exists(path+'\out'):  # 是否存在out文件夹
                    os.makedirs(path+'\out')  # 如果没有则创建
                fw = open(path+'\out' +'\'+ f1, 'w',encoding='utf-16')
                for line in f.readlines():   #遍历文件中每一行
                    print(line)
                    if curr_pwd in line:
                        print(curr_pwd)
                        fw.write(update_pwd)
                    else:
                        fw.write(line)
print('修改完成')
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/948062.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号