zoukankan      html  css  js  c++  java
  • 防火墙站名资源脚本

    import os
    import pandas

    excel_name = input("请将本软件和excel表格放在同一目录下,并输入excel表格的名字,不包括xlsx后缀:")+'.xlsx'
    print('使用的excel文件名为:', excel_name)
    excel_path = os.path.join(os.getcwd(), excel_name)


    def excel_to_txt(path):
    df = pandas.read_excel(path, sheet_name=0, header=0)
    txt_path_a = os.path.join(os.getcwd(), 'A网.txt')
    print(txt_path_a)
    txt_path_b = os.path.join(os.getcwd(), 'B网.txt')
    txt_path_station = os.path.join(os.getcwd(), '站名.txt')
    with open(txt_path_a, 'w') as f:
    for i in range(len(df)):
    name = df['name'][i]
    ip_a = df['ip_a'][i]
    mask_a = df['mask_a'][i]
    code = 'edit "%s" set subnet %s %s next ' % (name, ip_a, mask_a)
    f.write(code)
    print('A网.txt完成')
    with open(txt_path_b, 'w') as f:
    for i in range(len(df)):
    name = df['name'][i]
    ip_b = df['ip_b'][i]
    mask_b = df['mask_b'][i]
    code = 'edit "%s" set subnet %s %s next ' % (name, ip_b, mask_b)
    f.write(code)
    print('B网.txt完成')
    with open(txt_path_station, 'w') as f:
    for i in range(len(df)):
    name = df['name'][i]
    code = '%s ' % name
    f.write(code)
    print('站名.txt完成')


    if __name__ == '__main__':
    excel_to_txt(excel_path)
  • 相关阅读:
    Block为什么使用Copy?
    iOS运行时,如何增加成员变量
    安卓长按交互onCreateContextMenu的简单 用法
    iOS 检查版本号的代码
    git的基本使用
    svn的使用
    const 关键字及作用
    常见的内存分配
    保存字符串的方法
    指针的总结一(指针的定义)
  • 原文地址:https://www.cnblogs.com/sundahua/p/13586628.html
Copyright © 2011-2022 走看看