首页
金蝶系列
用友系列
鼎捷系列
OA协同办公
注册/登录
登录
注册
Search
1
Python 3.8 - ModuleNotFoundError: No module named 'flask._compat'
259 阅读
2
CentOS 7 - 安装iredMail 邮件服务器
252 阅读
3
Zabbix 4.0 源码安装
221 阅读
4
Kingdee-采购管理-T_PUR_CATALOGENTRY_R-采购目录_关联信息表
189 阅读
5
Python循环语句- for
179 阅读
默认分类
Windows
金蝶
OA
ERP
帆软
用友
Linux
数据库
/
Search
标签搜索
金蝶
管理
美萍
OA
Linux
qq
泛微
获取
破解
监控
用友
IPguard
KIS
Zabbix
python
帆软
活字格
MySQL
FineReport
k3cloud
SOSO
累计撰写
299
篇文章
累计收到
7
条评论
首页
栏目
默认分类
Windows
金蝶
OA
ERP
帆软
用友
Linux
数据库
页面
金蝶系列
用友系列
鼎捷系列
OA协同办公
推荐
登录
注册
搜索到
299
篇与
的结果
2022-05-11
Python循环语句- for
一、 基本语法for <循环变量> in <遍历对象>: <语句>二、例1In [3]: for i in [1, 2, 3, 4, 5]: ...: print(str(i)+'x'+str(i)+'='+str(i*i)) 1x1=1 2x2=4 3x3=9 4x4=16 5x5=25三、 for语句、continue语句、break语句In [7]: for i in [1, 2, 3, 4, 5]: ...: if i == 2: ...: continue ...: print(i) ...: if i == 4: ...: break ...: else: ...: print('end') 1 3 4 四、for循环遍历字典In [9]: dict = {'apple':10, 'banana':20, 'pear':30} In [10]: for key,value in dict.items(): ...: print(key,':',value) apple : 10 banana : 20 pear : 30五、 只遍历键In [11]: for key in dict.keys(): ...: print(key) apple banana pear六、 rang函数:语法range([start,] stop[, step] )start 可选参数: 起始数,默认值为0stop 终止数: 如果range只有一个参数x,那么range生产一个从0至x-1的整数列表step 可选参数:步长,即每次循环序列增长值。例1:In [12]: for i in range(5): ...: print(i) 0 1 2 3 4例2:In [13]: for i in range(0,10,2): ...: print(i) 0 2 4 6 8
2022年05月11日
179 阅读
0 评论
0 点赞
2022-05-10
Ubuntu-Netplan configuration examples
From:https://netplan.io/examples/Below are a collection of example netplan configurations for common scenarios. If you see a scenario missing or have one to contribute, please file a bug against this documentation with the example using the links at the bottom of this page. Thank you!ConfigurationTo configure netplan, save configuration files under /etc/netplan/ with a .yaml extension (e.g. /etc/netplan/config.yaml), then run sudo netplan apply. This command parses and applies the configuration to the system. Configuration written to disk under /etc/netplan/ will persist between reboots.Using DHCP and static addressingTo let the interface named ‘enp3s0’ get an address via DHCP, create a YAML file with the following:network: version: 2 renderer: networkd ethernets: enp3s0: dhcp4: trueTo instead set a static IP address, use the addresses key, which takes a list of (IPv4 or IPv6), addresses along with the subnet prefix length (e.g. /24). DNS information can be provided as well, and the gateway can be defined via a default route:network: version: 2 renderer: networkd ethernets: enp3s0: addresses: - 10.10.10.2/24 nameservers: search: [mydomain, otherdomain] addresses: [10.10.10.1, 1.1.1.1] routes: - to: default via: 10.10.10.1Connecting multiple interfaces with DHCPMany systems now include more than one network interface. Servers will commonly need to connect to multiple networks, and may require that traffic to the Internet goes through a specific interface despite all of them providing a valid gateway.One can achieve the exact routing desired over DHCP by specifying a metric for the routes retrieved over DHCP, which will ensure some routes are preferred over others. In this example, ‘enred’ is preferred over ‘engreen’, as it has a lower route metric:network: version: 2 ethernets: enred: dhcp4: yes dhcp4-overrides: route-metric: 100 engreen: dhcp4: yes dhcp4-overrides: route-metric: 200Connecting to an open wireless networkNetplan easily supports connecting to an open wireless network (one that is not secured by a password), only requiring that the access point is defined:network: version: 2 wifis: wl0: access-points: opennetwork: {} dhcp4: yesConnecting to a WPA Personal wireless networkWireless devices use the ‘wifis’ key and share the same configuration options with wired ethernet devices. The wireless access point name and password should also be specified:network: version: 2 renderer: networkd wifis: wlp2s0b1: dhcp4: no dhcp6: no addresses: [192.168.0.21/24] nameservers: addresses: [192.168.0.1, 8.8.8.8] access-points: "network_ssid_name": password: "**********" routes: - to: default via: 192.168.0.1Connecting to WPA Enterprise wireless networksIt is also common to find wireless networks secured using WPA or WPA2 Enterprise, which requires additional authentication parameters.For example, if the network is secured using WPA-EAP and TTLS:network: version: 2 wifis: wl0: access-points: workplace: auth: key-management: eap method: ttls anonymous-identity: "@internal.example.com" identity: "
[email protected]
" password: "v3ryS3kr1t" dhcp4: yesOr, if the network is secured using WPA-EAP and TLS:network: version: 2 wifis: wl0: access-points: university: auth: key-management: eap method: tls anonymous-identity: "@cust.example.com" identity: "
[email protected]
" ca-certificate: /etc/ssl/cust-cacrt.pem client-certificate: /etc/ssl/cust-crt.pem client-key: /etc/ssl/cust-key.pem client-key-password: "d3cryptPr1v4t3K3y" dhcp4: yesMany different modes of encryption are supported. See the Netplan reference page.Using multiple addresses on a single interfaceThe addresses key can take a list of addresses to assign to an interface:network: version: 2 renderer: networkd ethernets: enp3s0: addresses: - 10.100.1.38/24 - 10.100.1.39/24 routes: - to: default via: 10.100.1.1Interface aliases (e.g. eth0:0) are not supported.Using multiple addresses with multiple gatewaysSimilar to the example above, interfaces with multiple addresses can beconfigured with multiple gateways.network: version: 2 renderer: networkd ethernets: enp3s0: addresses: - 10.0.0.10/24 - 11.0.0.11/24 routes: - to: default via: 10.0.0.1 metric: 200 - to: default via: 11.0.0.1 metric: 300We configure individual routes to default (or 0.0.0.0/0) using the address of the gateway for the subnet. The metric value should be adjusted so the routing happens as expected.DHCP can be used to receive one of the IP addresses for the interface. In this case, the default route for that address will be automatically configured with a metric value of 100.Using Network Manager as a rendererNetplan supports both networkd and Network Manager as backends. You can specify which network backend should be used to configure particular devices by using the renderer key. You can also delegate all configuration of the network to Network Manager itself by specifying only the renderer key:network: version: 2 renderer: NetworkManagerConfiguring interface bondingBonding is configured by declaring a bond interface with a list of physical interfaces and a bonding mode. Below is an example of an active-backup bond that uses DHCP to obtain an address:network: version: 2 renderer: networkd bonds: bond0: dhcp4: yes interfaces: - enp3s0 - enp4s0 parameters: mode: active-backup primary: enp3s0Below is an example of a system acting as a router with various bonded interfaces and different types. Note the ‘optional: true’ key declarations that allow booting to occur without waiting for those interfaces to activate fully.network: version: 2 renderer: networkd ethernets: enp1s0: dhcp4: no enp2s0: dhcp4: no enp3s0: dhcp4: no optional: true enp4s0: dhcp4: no optional: true enp5s0: dhcp4: no optional: true enp6s0: dhcp4: no optional: true bonds: bond-lan: interfaces: [enp2s0, enp3s0] addresses: [192.168.93.2/24] parameters: mode: 802.3ad mii-monitor-interval: 1 bond-wan: interfaces: [enp1s0, enp4s0] addresses: [192.168.1.252/24] nameservers: search: [local] addresses: [8.8.8.8, 8.8.4.4] parameters: mode: active-backup mii-monitor-interval: 1 gratuitious-arp: 5 routes: - to: default via: 192.168.1.1 bond-conntrack: interfaces: [enp5s0, enp6s0] addresses: [192.168.254.2/24] parameters: mode: balance-rr mii-monitor-interval: 1Configuring network bridgesTo create a very simple bridge consisting of a single device that uses DHCP, write:network: version: 2 renderer: networkd ethernets: enp3s0: dhcp4: no bridges: br0: dhcp4: yes interfaces: - enp3s0A more complex example, to get libvirtd to use a specific bridge with a tagged vlan, while continuing to provide an untagged interface as well would involve:network: version: 2 renderer: networkd ethernets: enp0s25: dhcp4: true bridges: br0: addresses: [ 10.3.99.25/24 ] interfaces: [ vlan15 ] vlans: vlan15: accept-ra: no id: 15 link: enp0s25Then libvirtd would be configured to use this bridge by adding the following content to a new XML file under /etc/libvirtd/qemu/networks/. The name of the bridge in the tag as well as in need to match the name of the bridge device configured using netplan:<network> <name>br0</name> <bridge name='br0'/> <forward mode="bridge"/> </network>Attaching VLANs to network interfacesTo configure multiple VLANs with renamed interfaces:network: version: 2 renderer: networkd ethernets: mainif: match: macaddress: "de:ad:be:ef:ca:fe" set-name: mainif addresses: [ "10.3.0.5/23" ] nameservers: addresses: [ "8.8.8.8", "8.8.4.4" ] search: [ example.com ] routes: - to: default via: 10.3.0.1 vlans: vlan15: id: 15 link: mainif addresses: [ "10.3.99.5/24" ] vlan10: id: 10 link: mainif addresses: [ "10.3.98.5/24" ] nameservers: addresses: [ "127.0.0.1" ] search: [ domain1.example.com, domain2.example.com ]Reaching a directly connected gatewayThis allows setting up a default route, or any route, using the “on-link” keyword where the gateway is an IP address that is directly connected to the network even if the address does not match the subnet configured on the interface.network: version: 2 renderer: networkd ethernets: ens3: addresses: [ "10.10.10.1/24" ] routes: - to: default # or 0.0.0.0/0 via: 9.9.9.9 on-link: trueFor IPv6 the config would be very similar, with the notable difference being an additional scope: link host route to the router’s address required:network: version: 2 renderer: networkd ethernets: ens3: addresses: [ "2001:cafe:face:beef::dead:dead/64" ] routes: - to: "2001:cafe:face::1/128" scope: link - to: default # or "::/0" via: "2001:cafe:face::1" on-link: trueConfiguring source routingRoute tables can be added to particular interfaces to allow routing between two networks:In the example below, ens3 is on the 192.168.3.0/24 network and ens5 is on the 192.168.5.0/24 network. This enables clients on either network to connect to the other and allow the response to come from the correct interface.Furthermore, the default route is still assigned to ens5 allowing any other traffic to go through it.network: version: 2 renderer: networkd ethernets: ens3: addresses: - 192.168.3.30/24 dhcp4: no routes: - to: 192.168.3.0/24 via: 192.168.3.1 table: 101 routing-policy: - from: 192.168.3.0/24 table: 101 ens5: addresses: - 192.168.5.24/24 dhcp4: no routes: - to: default via: 192.168.5.1 - to: 192.168.5.0/24 via: 192.168.5.1 table: 102 routing-policy: - from: 192.168.5.0/24 table: 102Configuring a loopback interfaceNetworkd does not allow creating new loopback devices, but a user can add new addresses to the standard loopback interface, lo, in order to have it considered a valid address on the machine as well as for custom routing:network: version: 2 renderer: networkd ethernets: lo: match: name: lo addresses: [ 7.7.7.7/32 ]Integration with a Windows DHCP ServerFor networks where DHCP is provided by a Windows Server using the dhcp-identifier key allows for interoperability:network: version: 2 ethernets: enp3s0: dhcp4: yes dhcp-identifier: macConnecting an IP tunnelTunnels allow an administrator to extend networks across the Internet by configuring two endpoints that will connect a special tunnel interface and do the routing required. Netplan supports SIT, GRE, IP-in-IP (ipip, ipip6, ip6ip6), IP6GRE, VTI and VTI6 tunnels.A common use of tunnels is to enable IPv6 connectivity on networks that only support IPv4. The example below show how such a tunnel might be configured.Here, 1.1.1.1 is the client’s own IP address; 2.2.2.2 is the remote server’s IPv4 address, “2001:dead:beef::2/64” is the client’s IPv6 address as defined by the tunnel, and “2001:dead:beef::1” is the remote server’s IPv6 address.Finally, “2001:cafe:face::1/64” is an address for the client within the routed IPv6 prefix:network: version: 2 ethernets: eth0: addresses: - 1.1.1.1/24 - "2001:cafe:face::1/64" routes: - to: default via: 1.1.1.254 tunnels: he-ipv6: mode: sit remote: 2.2.2.2 local: 1.1.1.1 addresses: - "2001:dead:beef::2/64" routes: - to: default via: "2001:dead:beef::1"Configuring SR-IOV Virtual FunctionsFor SR-IOV network cards, it is possible to dynamically allocate Virtual Function interfaces for every configured Physical Function. In netplan, a VF is defined by having a link: property pointing to the parent PF.network: version: 2 ethernets: eno1: mtu: 9000 enp1s16f1: link: eno1 addresses : [ "10.15.98.25/24" ] vf1: match: name: enp1s16f[2-3] link: eno1 addresses : [ "10.15.99.25/24" ]
2022年05月10日
108 阅读
0 评论
0 点赞
2022-05-10
Python流程控制语句- if else
一、流程控制语句 if...elif...else语法:if <条件>: <语句> elif <条件>: <语句> else: <语句>1.1 例1num = input('Please input a integer:') num = int(num) if num < 0: print('输入了负数:%d' % num) elif num == 0: print('输入了一个0: %d' % num) else: print('输入了正数 %d' % num)1.2 例2score = input('输入得分数:') score = float(score) if score >= 90: print('成绩为优:') elif score >= 80: print('成绩为良:') elif score >= 60: print('成绩合格:') else: print('成绩不合格!')
2022年05月10日
89 阅读
0 评论
0 点赞
2022-05-10
Python数据类型之-列表、元组、字典
一、 列表 list1.1 列表常用操作函数列表操作描述list.append(x)列表尾部追加成员xlist.count(x)返回列表中的参数x出现的次数list.extend(list2)向列表中追加另一个列表list2list.index(x)返回参数x在列表中的索引序号list.insert(index, object)向列表中指定位置(index)插入数据(object)list.pop()删除列表中尾部的成员,并返回删除的成员list.remove(x)删除列表中的指定成员list.reverse()将列表中成员的顺序反转list.sort将列表中成员排序1.2 append函数In [8]: list = ['a', 'b', 'c'] In [9]: list.append('x') In [10]: list Out[10]: ['a', 'b', 'c', 'x']1.3 extend函数In [11]: list = ['a', 'b', 'c'] In [12]: list2 = [1, 2, 3] In [13]: list.extend(list2) In [14]: list Out[14]: ['a', 'b', 'c', 'x', 1, 2, 3]1.4 remove函数In [15]: list = ['a', 'b', 'c'] In [16]: list.remove('c') In [17]: list Out[17]: ['a', 'b']1.5 pop函数In [19]: list = ['a', 'b', 'c', 'd'] In [20]: list.pop() Out[20]: 'd' In [21]: list Out[21]: ['a', 'b', 'c']1.6 insert函数In [26]: list = ['a', 'b', 'c', 'x', 1, 2, 3] In [27]: list.insert(3, 'd') In [28]: list Out[28]: ['a', 'b', 'c', 'd', 'x', 1, 2, 3]二、列表切片2.1 切片常用方法使用形式描述list[:]取全部元素list[0:]取全部元素list[:-1]取除最后中一外元素之外的所有元素list[1:3]得到[2,3]list[::2]每隔1个取一个元素list[0:5:2]从0至4每隔1个取元素list[::-1]从右至左取全部元素list[5:0:-2]从5至0(不含0),每隔一个取元素#取全部元素 In [4]: list = [1, 2, 3, 4, 5] In [5]: list[:] Out[5]: [1, 2, 3, 4, 5] In [6]: list[0:] Out[6]: [1, 2, 3, 4, 5] #取除最后中一外元素之外的所有元素 In [7]: list[:-1] Out[7]: [1, 2, 3, 4] #得到[2,3] In [8]: list[1:3] Out[8]: [2, 3] #每隔1个取一个元素 In [9]: list[::2] Out[9]: [1, 3, 5] #从0至4每隔1个取元素 In [11]: list[0:5:2] Out[11]: [1, 3, 5] #从右至左取全部元素 In [12]: list[::-1] Out[12]: [5, 4, 3, 2, 1]2.2 列表内置方法方法描述len(list)返回列表元素长度min(list)返回列表中最小值max(list)返回列表中最大值sum(list, start)返回列表中元素的和all(list)列表中所有项为真,则返回真,否则返回假any(list)列表中有一项为真,则返回真,否则返回假2.3 列表求和 sum(list)In [15]: list Out[15]: [1, 2, 3, 4, 5] In [16]: sum(list) Out[16]: 15 In [17]: sum(list, 15) Out[17]: 302.4 列表最大值、最小值In [19]: list = [1, 2, 3, 4, 5] In [20]: max(list) Out[20]: 5 In [21]: min(list) Out[21]: 1三、元组 tuple元组与列表不同的是元组一旦建立是不能改变的,既不能改变其中的数据项,也不能添加和删除数据项。3.1 创建元组# 创建只有一个元素的元组,后面必须加 “,” In [29]: tuple1 = (1,) In [30]: tuple1 = (1, 2, 3) In [31]: tuple1[0] Out[31]: 1 # 修改元组数据项报错 In [32]: tuple1[0] = 'x' ---------------------------------------------------------- TypeError Traceback (most <ipython-input-32-5ecba0cdf597> in <module> ----> 1 tuple1[0] = 'x' TypeError: 'tuple' object does not support item assignment四、字典 dict字典中每个成员是以“键:值”对的形式存在的,与列表不同的是,字典是无序的,在字典中通过键来访问成员,而不能通过索引位置来访问成员。4.1 字典操作函数字典操作描述dict.clear()清空字典dict.copy()复制字典dict.get(k,[default])获得k键对应的值,不存在则返回defaultdict.items()获得由键和值组成的迭代器dict.keys()获得键的迭代器dict.pop(k)删除k:v成员对dict.update(dict1)从另一个字典更新成员(不存在就创建,存在则覆盖)dict.values()获得值的迭代器dict.fromkeys(iter,value)以列表或元组中给字的键建立字典,默认值为valuedict.popitem()从字典中删除任一k:v项并返回它dict.setdefault(k,default)若字典中存在key值为k的,则返回其对应的值;否则在字典中建立一个k:default字典成员4.2 清空字典 dict.clear()In [42]: dict = {'name':'zs', 'age':20} In [43]: dict Out[43]: {'name': 'zs', 'age': 20} In [44]: dict.clear() In [45]: dict Out[45]: {}4.3 复制字典 dict.copy()In [65]: dict = {'name':'zs', 'age':20} In [66]: dict1 = {} In [67]: dict1 Out[67]: {} In [68]: dict1 = dict.copy() In [69]: dict1 Out[69]: {'name': 'zs', 'age': 20}4.4 获取键对应的值,不存在则返回default: dict.get(key, default)In [74]: dict = {'name':'zs', 'age':20} In [75]: dict.get('name') Out[75]: 'zs' In [76]: dict.get('gender', 0) Out[76]: 04.5 获得键值对的迭代器 dict.items(); dict.keys(), dict.values()In [77]: dict = {'name':'zs', 'age':20} In [78]: dict.items() Out[78]: dict_items([('name', 'zs'), ('age', 20)]) In [79]: dict.keys() Out[79]: dict_keys(['name', 'age']) In [80]: dict.values() Out[80]: dict_values(['zs', 20])4.6 更新字典成员 dict.update()In [84]: dict = {'name':'zs', 'age':20} In [85]: dict.update({'address':'SH'}) In [86]: dict Out[86]: {'name': 'zs', 'age': 20, 'address': 'SH'}4.7 删除字典成员 dict.pop()In [86]: dict Out[86]: {'name': 'zs', 'age': 20, 'address': 'SH'} In [87]: dict.pop('address') Out[87]: 'SH' In [88]: dict Out[88]: {'name': 'zs', 'age': 20}
2022年05月10日
111 阅读
0 评论
0 点赞
2022-05-09
Python 数据类型之-字符串
一、 常见字符串函数字符串操作描述string.capitalize()将字符串的第一个字母大写string.count()获得字符串中某一子字符串数量string.find()获得字符串中某一子字符串的起始位置, 无则返回 -1string.isalnum()检测字符串是仅包含0~9A~Za~zstring.isalpha()检测字符串是仅包含A~Za~zstring.isdigit()检测字符串是仅包含数字string.islower()检测字符串是否均为小写字母string.isupper()检测字符串是否均为大写字母string.isspace()检测字符串中所有字符是否均为空白字符string.istitle()检测字符串中的单词是否为首字母大写string.join()连接字符串string.lower()将字符串全部转换为小写string.upper()将字符串全部转换为大写string.split()分割字符串string.swapcase()将字符串中大写字母转換为小写,小写字母转为大写string.title()将字符串中的单词首字母大写len(string)获取字符串长度1.1 将字符串中的第一个字母大写In [1]: str = "python" In [2]: print(str.capitalize()) Python1.2 获得字符串中某一子字符串数量In [3]: str = "i love python" In [4]: print(str.count('o')) 21.3 获得字符串中某一子字符串的起始位置, 无则返回 -1In [5]: str = "i love python" In [6]: print(str.find('p')) 71.4 检测字符串是仅包含0~9A~Za~zIn [15]: str = "i love python" In [16]: print(str.isalnum()) False In [17]: str1 = 'abcd123ABC' In [18]: print(str1.isalnum()) True1.5 检测字符串是仅包含A~Za~zIn [19]: str = "i love python" In [20]: print(str.isalpha()) False In [21]: str1 = 'abcdABC' In [22]: print(str1.isalpha()) True1.6 连接字符串In [30]: str1 = 'abc' In [31]: str2 = '123' In [32]: str1.join(str2) Out[32]: '1abc2abc3'1.7 分割字符串In [33]: str = 'abcdefg123' In [34]: str.split('c') Out[34]: ['ab', 'defg123'] In [35]: str = 'abc, def, ghi' In [36]: str.split(',') Out[36]: ['abc', ' def', ' ghi'] # 指定分割次数 In [72]: str.split(' ',1) Out[72]: ['I', 'love python'] # 或 In [73]: str.split(' ', maxspli=1) Out[73]: ['I', 'love python']1.8 字符串大小写转换In [44]: str = 'abc' In [45]: print(str.upper()) ABC In [46]: str = 'ABC' In [47]: print(str.lower()) abc In [48]: str = 'abcdEFGH' In [49]: print(str.swapcase()) ABCDefgh1.9 获取字符串长度In [54]: str = 'abcd123' In [55]: len(str) Out[55]: 7二、格式化字符串格式化说明%c单个字符%d十进制整数%o八进制整数%s字符串%x十六进制整数,其中的字母小写%X十六进制整数,其中的字母大写2.1 格式化 %sIn [28]: str = 'Python' In [29]: strFormat = "I love %s" % str In [30]: strFormat Out[30]: 'I love Python'2.2 格式化 %dIn [31]: num1 = 10 In [32]: num2 = 20 In [33]: result = num1 + num2 In [34]: print("%d + %d = %d" % (num1, num2, result)) 10 + 20 = 30
2022年05月09日
83 阅读
0 评论
0 点赞
1
...
52
53
54
...
60