python网络自动化ncclient模块,netconf协议检索与下发交换机配置

个人博客地址

http://www.darkghost.life

以juniper和华为设备为例

交换机必要配置,配置简单,使用ssh模式传输

#juniperset system services netconf ssh#华为

local-user netconf-dark password irreversible-cipher $1c$16[R/:A_aG$sG-KWmUb!SCz=R9y[P%KE&9.’P”+:XJ=-`

netconf
source ip 10.0.3.105

netconf使用XML格式来请求和接收数据,使用简单举例

使用ssh连接交换机

C:\Users\86185>ssh  10.0.3.101 -s netconf
Password:
<!-- No zombies were killed during the creation of this user interface -->
<!-- user dark, class j-super-user -->
="urn:ietf:params:xml:ns:netconf:base:1.0">
  >
    >urn:ietf:params:netconf:base:1.0
    >urn:ietf:params:netconf:capability:candidate:1.0
    >urn:ietf:params:netconf:capability:confirmed-commit:1.0
    >urn:ietf:params:netconf:capability:validate:1.0
    >urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file
    >urn:ietf:params:xml:ns:netconf:base:1.0
    >urn:ietf:params:xml:ns:netconf:capability:candidate:1.0
    >urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0
    >urn:ietf:params:xml:ns:netconf:capability:validate:1.0
    >urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file
    >http://xml.juniper.net/netconf/junos/1.0
    >http://xml.juniper.net/dmi/system/1.0
  </capabilities>
  -id>65770
</hello>
]]>]]>

juniper请求端口信息


    -interface-information>
        -name>xe-0/0/1
        />
    </get-interface-information>
</rpc>

juniper提交配置

华为请求trunk接口信息

"1.0" encoding="UTF-8"?>
="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1024">
  >
    <filter type="subtree">
      ="http://www.huawei.com/netconf/vrp" content-version="1.0" format-version="1.0">
        >
          >
            >
            >
            >
          </TrunkIf>
        </TrunkIfs>
      </ifmtrunk>
    </filter>
  </get>
</rpc>

以上是netconf的简单原生操作,如果我们要在python环境中使用netconf,首先需要下载读取YANG文件,封装get get-config commit edit_config lock unlock等功能,根据不同厂商选择不同的YANG API,其次还需要创建sock连接,通过ssh交互netconf报文,设备厂商繁多,各家功能对应的TAG名称也不一致,自己一步一步写起来太过复杂,好在python中有较为成熟的库可供我们使用

ncclient

ncclient是一个用于NETCONF客户端的Python库,可以在python环境中使用netconf协议检索下发交换机配置

host = '10.0.3.105'
username = 'username'
passwd = 'password'
#connect()返回一个连接对象
netconf_connection = manager.connect(host=host,
                                     username=username,
                                     password=passwd,
                                     port=830,
                                     hostkey_verify=False
                                     )

#获取交换机端口简要信息XML语句
interface_index = """"""

rpc_conf = netconf_connection.get(filter =('subtree',interface_info))

print(rpc)

得到如下信息

python网络自动化ncclient模块,netconf协议检索与下发交换机配置python网络自动化ncclient模块,netconf协议检索与下发交换机配置
"1.0" encoding="UTF-8"?>"urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">"urn:huawei:params:xml:ns:yang:huawei-device">XGigabitEthernet0/0/11falseXGigabitEthernet0/0/22falseXGigabitEthernet0/0/33falseXGigabitEthernet0/0/44falseXGigabitEthernet0/0/55falseXGigabitEthernet0/0/66falseXGigabitEthernet0/0/77falseXGigabitEthernet0/0/88falseXGigabitEthernet0/0/99falseXGigabitEthernet0/0/1010falseXGigabitEthernet0/0/1111falseXGigabitEthernet0/0/1212falseXGigabitEthernet0/0/1313falseXGigabitEthernet0/0/1414falseXGigabitEthernet0/0/1515falseXGigabitEthernet0/0/1616falseXGigabitEthernet0/0/1717falseXGigabitEthernet0/0/1818falseXGigabitEthernet0/0/1919falseXGigabitEthernet0/0/2020falseXGigabitEthernet0/0/2121falseXGigabitEthernet0/0/2222falseXGigabitEthernet0/0/2323falseXGigabitEthernet0/0/2424falseXGigabitEthernet0/0/2525falseXGigabitEthernet0/0/2626falseXGigabitEthernet0/0/2727falseXGigabitEthernet0/0/2828falseXGigabitEthernet0/0/2929falseXGigabitEthernet0/0/3030falseXGigabitEthernet0/0/3131falseXGigabitEthernet0/0/3232falseXGigabitEthernet0/0/3333falseXGigabitEthernet0/0/3434falseXGigabitEthernet0/0/3535falseXGigabitEthernet0/0/3636falseXGigabitEthernet0/0/3737falseXGigabitEthernet0/0/3838falseXGigabitEthernet0/0/3939falseXGigabitEthernet0/0/4040falseXGigabitEthernet0/0/4141falseXGigabitEthernet0/0/4242falseXGigabitEthernet0/0/4343falseXGigabitEthernet0/0/4444false100GE0/0/11false100GE0/0/22false40GE0/0/33false40GE0/0/44false40GE0/0/55false40GE0/0/66false

View Code

请问这一堆乱糟糟的是什么东西,也没个换行符-_-!

别急,我们需要封装一些功能进去

1 #首先自己写一个类
 2 class Netconf:
 3     #封装一些connect必要的参数
 4     def __init__(self,*args,**kwargs):
 5         self.host = kwargs['host']
 6         self.port = kwargs.get('port',830)
 7         self.username = kwargs['username']
 8         self.passwd = kwargs['passwd']
 9         self.hostkey_verify=kwargs.get('hostkey_verify',False)
10     #connect方法
11     def conn(self):
12         try:
13             netconf_conn =  manager.connect(host=self.host,port=self.port,username=self.username,password=self.passwd,hostkey_verify=self.hostkey_verify)
14             return netconf_conn
15         except Exception as a:
16             print(a)
17             print("""
18             ---------------------------------------------------------------------------------------
19             sample: Netconf(host='10.0.3.105',username='netconf-dark',passwd='1234567',port=830)
20             """
21             )
22     #get_config方法,获取的交换机的所有配置
23     def get_conf(self):
24         netconf_conn = self.conn()
25         return netconf_conn.get_config(source='running').data_xml
26     #写个方法处理下得到的数据,以xml树形格式进行返回
27     def get_xml(self,command=None):
28         netconf_conn = self.conn()
29         rpc_replay = netconf_conn.get(filter=('subtree',command)).data_xml
30         rpc_xml = xml.dom.minidom.parseString(rpc_replay).toprettyxml()
31         return rpc_replay
32     #以字典形式进行返回,方便做数据处理
33     def get_dic(self,command=None):
34         netconf_conn = self.conn()
35         rpc_replay = netconf_conn.get(filter=('subtree',command)).data_xml
36         rpc_dict = xmltodict.parse(rpc_replay)
37         return rpc_dict
38     #以json方式进行返回
39     def get_json(self,command=None):
40         rpc_replay = self.get_dic(command)
41         rpc_json = json.dumps(rpc_replay, indent=1)
42         return rpc_json
43     def server_capabilities(self):
44         netconf_conn = self.conn()
45         return netconf_conn.server_capabilities

我们来用下好不好使

interface_info = """"""
conn = Netconf(host='10.0.3.105',username='netconf',passwd='netconf123456')
rpc_json = conn.get_json(interface_index)
rpc_xml = conn.get_xml(interface_index)
with open('/home/dark/interface_info.json') as a:
    a.write(rpc_json)
with open('/home/dark/interface_info.xml') as a:
    a.write(rpc_xml)

运行以上代码

python网络自动化ncclient模块,netconf协议检索与下发交换机配置python网络自动化ncclient模块,netconf协议检索与下发交换机配置
#json格式,输出太长,截取一小段
{
 "data": {
  "@xmlns": "urn:ietf:params:xml:ns:netconf:base:1.0",
  "@xmlns:nc": "urn:ietf:params:xml:ns:netconf:base:1.0",
  "interfaces-state": {
   "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-interfaces",
   "interface": [
    {
     "name": "NULL0"
    },
    {
     "name": "MEth0/0/1"
    },
    {
     "name": "Vlanif1"
    },
    {
     "name": "XGigabitEthernet0/0/1"
    },
    {
     "name": "XGigabitEthernet0/0/2"
    },
    {
     "name": "XGigabitEthernet0/0/3"
    },
    {
     "name": "XGigabitEthernet0/0/4"
    },
    {
     "name": "40GE0/0/3"
    },
    {
     "name": "40GE0/0/4"
    },
    {
     "name": "40GE0/0/5"
    },
    {
     "name": "40GE0/0/6"
    },
    {
     "name": "LoopBack0",
     "ipv4": {
      "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-ip",
      "address": {
       "ip": "192.168.35.60",
       "netmask": "255.255.255.255",
       "origin": "static"
      }
     }
    },
    {
     "name": "Vlanif48",
     "ipv4": {
      "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-ip",
      "address": {
       "ip": "10.40.0.70",
       "netmask": "255.255.255.252",
       "origin": "static"
      }
     }
    },
    {
     "name": "LoopBack1",
     "ipv4": {
      "@xmlns": "urn:ietf:params:xml:ns:yang:ietf-ip",
      "address": {
       "ip": "192.168.39.17",
       "netmask": "255.255.255.252",
       "origin": "static"
      }
     }
    },
    {
     "name": "MEth0/0/2"
    }
   ]
  }
 }
}

json格式

python网络自动化ncclient模块,netconf协议检索与下发交换机配置python网络自动化ncclient模块,netconf协议检索与下发交换机配置
#XML格式,输出太长,截取一小段
"1.0" ?>
"urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
    "urn:ietf:params:xml:ns:yang:ietf-interfaces">

            NULL0

            MEth0/0/1

            Vlanif1

            XGigabitEthernet0/0/1

            XGigabitEthernet0/0/2

            XGigabitEthernet0/0/3

            40GE0/0/3

            40GE0/0/4

            40GE0/0/5

            40GE0/0/6

            LoopBack0
            "urn:ietf:params:xml:ns:yang:ietf-ip">

                    192.168.35.60
                    255.255.255.255
                    static

            Nve1

            Vlanif48
            "urn:ietf:params:xml:ns:yang:ietf-ip">

                    10.40.0.70
                    255.255.255.252
                    static

            LoopBack1
            "urn:ietf:params:xml:ns:yang:ietf-ip">

                    192.168.39.17
                    255.255.255.252
                    static

            MEth0/0/2

XML格式

代码中的interfac_info的XML字符串来自哪里?这就需要用到YANG API,有公共的YANG,各家厂商也有自己的YANG

例如华为CE系列的https://support.huawei.com/hedex/hdx.do?docid=EDOC1000179511&lang=zh&id=library_change_preview&from=HedExLite

也可以通过get请求格式化成XML文档树,如下

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

juniper还可以通过命令行输出XML格式,华为没找类似功能,可能是我手里的交换机太垃圾

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

如果是通过YANG API文件检索的字符串,我们用ncclient执行操作时只需要content部分,如下黑色框区域

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

如果是get到的XML文档树,需要哪个模块就点开哪个模块复制就行,例如我们需要获取每个端口的ipaddress,如下

先找到interfaces-state这一层,展开

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

我们可以获取关于接口的N多信息,如果我们只需要其中的一部分可以进行如下操作

interface_info = """"""
#根层必须有,子层的父层也必须有,到子层后需要哪些标签就写对应的标签
rpc_xml = conn.get_xml(interface_info)
print(rpc_xml)

输出如下,截取部分

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

同样的,juniper通过GET到XML结构树,这里不得不感叹下juniper的便捷,灵活性,从以下输出可以看到juniper的XML树形结构与配置命令的层次结构极其相似

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

来get一下接口信息,这次输出json格式

rpc_json = conn.get_json('')
print(rpc_json)

运行以上代码,截取一小部分

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

以上是ncclient的GET操作,ncclient的manager模块还有许多其他方法,如下

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

接着说edit_config和commit,discard_changss,这些方法用于对交换机配置的变更,我们需要封装进我们自己的类,改变如下

1 class Netconf:
 2     #封装一些connect必要的参数
 3     def __init__(self,*args,**kwargs):
 4         self.host = kwargs['host']
 5         self.port = kwargs.get('port',830)
 6         self.username = kwargs['username']
 7         self.passwd = kwargs['passwd']
 8         self.hostkey_verify=kwargs.get('hostkey_verify',False)
 9         self.device_params=kwargs.get('device_params',None)
10     #connect方法
11     def conn(self):
12         try:
13             netconf_conn =  manager.connect(host=self.host,port=self.port,username=self.username,\
14                 password=self.passwd,hostkey_verify=self.hostkey_verify,device_params=self.device_params)
15             return netconf_conn
16         except Exception as a:
17             print(a)
18             print("""
19             ---------------------------------------------------------------------------------------
20             sample: Netconf(host='10.0.3.105',username='netconf-dark',passwd='1234567',port=830)
21             """
22             )
23     #get_config方法,获取的交换机的所有配置
24     def get_conf(self):
25         netconf_conn = self.conn()
26         return netconf_conn.get_config(source='running').data_xml
27     #写个方法处理下得到的数据,以xml树形格式进行返回
28     def get_xml(self,command=None):
29         netconf_conn = self.conn()
30         rpc_replay = netconf_conn.get(filter=('subtree',command)).data_xml
31         rpc_xml = xml.dom.minidom.parseString(rpc_replay).toprettyxml()
32
33         return rpc_xml.strip()
34     #以字典形式进行返回,方便做数据处理
35     def get_dic(self,command=None):
36         netconf_conn = self.conn()
37         rpc_replay = netconf_conn.get(filter=('subtree',command)).data_xml
38         rpc_dict = xmltodict.parse(rpc_replay)
39         return rpc_dict
40     #以json方式进行返回
41     def get_json(self,command=None):
42         rpc_replay = self.get_dic(command)
43         rpc_json = json.dumps(rpc_replay, indent=1)
44         return rpc_json
45     #server端所支持的能力,返回迭代器
46     def server_capabilities(self):
47         netconf_conn = self.conn()
48         return netconf_conn.server_capabilities
49     #edit_config方法,target可使用candidate或running
50     def edit(self,command=None,target='candidate'):
51         netconf_conn = self.conn()
52         reply = netconf_conn.edit_config(target=target,config=command)
53         return reply
54     #清除未提交配置
55     def rollback(self):
56         netconf_conn = self.conn()
57         # netconf_conn.rpc('')
58         return netconf_conn.discard_changes()
59
60     #提交配置,confirmed代表是否进行回滚,timout表示多久回滚
61     def commit(self,confirmed=False,timeout=None):
62         netconf_conn = self.conn()
63         return netconf_conn.commit(confirmed=confirmed,timeout=timeout)

edit_config方法有一个必要的参数,config,XML格式,target参数需要注意,值可为candidate或running,对于juniper必须使用candidate,因为juniper配置完设备后需要commit提交配置

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

首先我们使用 server_capabilities方法看下设备是否支持edit_config

jun_conn = Netconf(host='10.0.3.101',username='username',passwd='passwd',port=1211,device_params={'name':'junos'})
hw_conn = Netconf(host='10.0.3.105',username='netconf',passwd='passwd')

for cap in hw_conn.server_capabilities():
    print(cap)

for cap in jun_conn.server_capabilities():
    print(cap)

输出如下,juniper对网络可编程支持性较好,操作舒服,以下案例均使用juniper设备

#HW

rn:ietf:params:netconf:base:1.0
urn:ietf:params:netconf:base:1.1
urn:ietf:params:netconf:capability:writable-running:1.0
urn:ietf:params:netconf:capability:candidate:1.0
urn:ietf:params:netconf:capability:startup:1.0
urn:ietf:params:netconf:capability:rollback-on-error:1.0
urn:ietf:params:netconf:capability:with-defaults:1.0
urn:ietf:params:netconf:capability:notification:1.0
urn:ietf:params:xml:ns:yang:1?revision=2017-02-20&module=yang
urn:ietf:params:xml:ns:yang:ietf-inet-types?revision=2013-07-15&module=ietf-inet-types
urn:ietf:params:xml:ns:yang:ietf-yang-types?revision=2013-07-15&module=ietf-yang-types
urn:ietf:params:xml:ns:yang:ietf-yang-library?revision=2018-01-17&module=ietf-yang-library
urn:ietf:params:xml:ns:yang:ietf-interfaces?revision=2014-05-08&module=ietf-interfaces&feature=arbitrary-names,pre-provisioning,if-mib#输出太多,截取一部分,如上支持的module,测试交换机是s6720,xml固定格式是#最后的yang:后面跟交换机支持的模块,操作对应的模块# 操作类型前需要跟前面一长串
#juniper
urn:ietf:params:netconf:base:1.0
urn:ietf:params:netconf:capability:candidate:1.0
urn:ietf:params:netconf:capability:confirmed-commit:1.0
urn:ietf:params:netconf:capability:validate:1.0
urn:ietf:params:netconf:capability:url:1.0?scheme=http,ftp,file
urn:ietf:params:xml:ns:netconf:base:1.0
urn:ietf:params:xml:ns:netconf:capability:candidate:1.0
urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0
urn:ietf:params:xml:ns:netconf:capability:validate:1.0
urn:ietf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file
http://xml.juniper.net/netconf/junos/1.0
http://xml.juniper.net/dmi/system/1.0

来使用下我们新增的方法,通用YANG API edit_config方法使用的tag是

jun_conn = Netconf(host='10.0.3.101',username='usernam',passwd='password',port=1211,device_params={'name':'junos'})

snmp = '''

        dark123456
        read-only

'''
jun_conn.edit(snmp)

运行以上代码后在设备上可以看到配置已经下发,但未提交,需要注意的是对于华为设备如果candidate数据库中有未提交配置时不可操作running数据库

dark@Test-Route# show | compare
[edit snmp]
    community 000123a { ... }
+   community dark123456 {
+       authorization read-only;
+   }

[edit]

dark@Test-Route> show configuration snmp | display set
set snmp community test authorization read-only

undefined

运行以下代码进行配置回滚

jun_conn.rollback()

执行后在设备上查看未提交配置为空

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

让我们回到下发配置未提交时,执行以下方法,commit并在1分钟后回滚配置

jun_conn.edit(snmp)
jun_conn.commit(confirmed=True,timeout=60)

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

可以看到配置将在1分钟内回滚

执行jun_conn.commit(),查看设备配置,配置已经下发并提交

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

然后我们进行配置删除

执行以下代码

del_snmp = '''

        dark123456
        read-only

'''

jun_conn.edit(del_snmp)
jun_conn.commit()

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

配置已删除

再试下华为设备,添加vlan 671

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

执行以下代码

vlan = '''

                    671

'''
hw_conn.edit(command=vlan,target='running')

python网络自动化ncclient模块,netconf协议检索与下发交换机配置

删除vlan执行以下代码

del_vlan = '''

                    671

'''
hw_conn.edit(del_vlan)

至此ncclient基本增删改查方法与格式化输出封装完毕

出门溜娃,下周继续……………..

Original: https://www.cnblogs.com/darkchen/p/15248377.html
Author: 奔波的驱魔人
Title: python网络自动化ncclient模块,netconf协议检索与下发交换机配置

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/714122/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • 学习vbs

    个人总结: 官方文档: 简单总结: Original: https://www.cnblogs.com/cjin-01/p/16813164.htmlAuthor: 2337Tit…

    技术杂谈 2023年7月23日
    082
  • 猪齿鱼开源四周年庆典,邀您共享精彩瞬间

    520真情相遇,「猪齿鱼」与你相伴, 从此一番过往皆是你! 在这样一个充满爱与温馨的日子里,「猪齿鱼」也迎来了自己四周岁的生日。小伙伴们,让我们一起坐上时光穿梭机,回顾「猪齿鱼」的…

    技术杂谈 2023年7月23日
    078
  • 腾讯云Linux连接ssh失败问题

    前言 用腾讯云服务器Ubuntu搭建完SSH服务后,隔了一段时间重装了服务器系统,搭建的时候想着直接按照原先的博客梭哈就完事了Windows10公钥远程连接Linux服务器结果就是…

    技术杂谈 2023年6月21日
    097
  • centospython3虚拟环境

    在使用 Python 语言时,通过 pip(pip3)来安装第三方包,但是由于 pip 的特性,系统中只能安装每个包的一个版本。但是在实际项目开发中,不同项目可能需要第三方包的不同…

    技术杂谈 2023年7月24日
    074
  • 性能测试案例全过程方案六———购物流程(重要!!!)

    代码改变世界 Cnblogs Dashboard Login 2022-01-15 22:19 清风软件测试开发 阅读(9 ) 评论() 编辑 性能测试案例全过程方案六 模拟多用户…

    技术杂谈 2023年5月31日
    0116
  • C# 窗体DataGridView单元格内多个按钮

    在网上找了两种,基本一样,不同点是把button控件”画”在单元格,还是用画笔生成元素”画”在单元格 1、C# 窗体DataGrid…

    技术杂谈 2023年5月31日
    077
  • GRU

    在神经网络发展的过程中,几乎所有关于LSTM的文章中对于LSTM的结构都会做出一些变动,也称为LSTM的变体。其中变动较大的是门控循环单元(Gated Recurrent Unit…

    技术杂谈 2023年7月11日
    094
  • wps Excel中怎么定位空白区域后向下填补同类项?

    转自:https://jingyan.baidu.com/article/fea4511a1e5c4cb6bb912597.html wps Excel中怎么定位空白区域后向下填补…

    技术杂谈 2023年5月31日
    0210
  • 如何将Excel中数据前的空格去除

    我们在工作中有时会碰到格式不统一的数据,这时会需要将数据前的空格去除,那么该如何操作呢? 下面小编就来具体介绍一下步骤吧~ Original: https://www.cnblog…

    技术杂谈 2023年5月31日
    0124
  • 记录XorDDos木马清理步骤

    1.检查 查看定时任务文件发现有两个异常定时任务 [root@manage ~]# cat /etc/crontab user-name command to be execute…

    技术杂谈 2023年7月25日
    066
  • Zabbix-企业级监控系统

    Zabbix-企业级监控系统 Zabbix 手册-官网 1.Zabbix简介 Zabbix 是一款监控网络的众多参数以及服务器、虚拟机、应用程序、服务、数据库、网站、云等的健康和完…

    技术杂谈 2023年7月11日
    089
  • Mall商城的高级篇的开发(二)性能压测和性能监控

    Mall商城的高级篇的开发(二) 性能压测–压力测试 压力测试考察当前软件硬件环境下系统所能承受的最大负荷并帮助找出系统的瓶颈所在。压测都是为了系统在上线的处理能力和稳…

    技术杂谈 2023年7月11日
    087
  • 是时候使用 YAML 来做配置或数据文件了

    概述 我们做程序,经常需要用到配置信息,回顾一下这么多年的搬砖生涯,我记得用过多种格式的文件来定义配置信息,例如 ini&#x6587;&#x4EF6;, xml&…

    技术杂谈 2023年5月31日
    087
  • Linux文件属性及权限

    Linux文件属性及权限 首先我们以root用户的身份登录linux,执行ls -al 查看文件: 文件类型: 【d】 代表目录(directory)、【-】代表文件、【l】代表链…

    技术杂谈 2023年7月11日
    065
  • 循环神经网络 RNN

    生活中,我们经常会遇到或者使用一些时序信号,比如自然语言语音,自然语言文本。以自然语言文本为例,完整的一句话中各个字符之间是有时序关系的,各个字符顺序的调换有可能变成语义完全不同的…

    技术杂谈 2023年7月11日
    077
  • requests上传文件进度条

    python;gutter:true; import os import requests</p> <p>class ChunkIO:</p> …

    技术杂谈 2023年6月21日
    063
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球