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)
  • 相关阅读:
    《代码阅读方法与实践》阅读笔记之二
    《代码阅读方法与实践》阅读笔记一
    专业实训题目需求分析
    阅读计划
    第二阶段Sprint10
    第二阶段Sprint9
    第二阶段Sprint8
    第二阶段Sprint7
    第二阶段个人工作总结(8)
    第二阶段个人工作总结(7)
  • 原文地址:https://www.cnblogs.com/sundahua/p/13586628.html
Copyright © 2011-2022 走看看