Python: a simple method for converting the subnet mask and a python Subnet Mask
This article describes how to convert the subnet mask in Python. We will share this with you for your reference. The details are as follows:
Here, t
be extracted by an array named key;The Savetxt (), Loadtxt () function can read and write a text file that holds a one-dimensional and two-dimensional array, outputs the text separated by the spacer, specifies the spacer by the delimiter parameter, and the default output is in the form of '%.18e ', separated by a space by default.4. Memory-mapped arraysCreates a memory-mapped array from a file that reads the specified offset data,> without reading the entire file into memory by Memmap ():FileNa
If we want to quickly get an IP address segment has how many IP, quickly get IP address segment subnet mask, or quickly get a binary IP address, then you can learn.This article uses a Python IP analysis module IPY implementation, first install the IPY modulewget https://pypi.python.org/packages/88/28/79162bfc351a3f1ab44d663ab3f03fb495806fdb592170990a1568ffbf63/IPy-0.83.tar.gztar -xf IPy-0.83.tar.gz cd IPy-0
in C language so faster than pickle.#!/usr/bin/python#Wed Jan 9 17:40:54 CST 2013Import Cpickle as PShoplistfile= ' Shoplist.data 'shoplist=[' apple ', ' egg ', ' banana 'F=file (Shoplistfile, ' W ')P.dump (SHOPLIST,F)F.closeF=file (Shoplistfile)Storedlist=p.load (f)Print StoredlistUse import: As syntax. So that we can use the module name with the segment.Python also has exception handling. With try. Except for exception handling. We put the usual st
Python obtains all Nic ip addresses, mask and broadcast address instance code, and pythonip
This article mainly studies how to use Python to obtain the ip addresses, masks, and broadcast addresses of all NICs on the local machine, and shares the related instance code. The details are as follows.
After searching for a day, I did not find a proper piece of code to
This article mainly introduces Python's simple method to implement subnet mask conversion, and involves Python string-related operation skills. If you need it, refer to the following example to describe Python's simple method to implement subnet mask conversion. We will share this with you for your reference. The details are as follows:
Here, the subnet
One day, using Centos7, when discovering the network configuration, the subnet mask needs to be converted manually, because the CENTOS7 network is configured as follows:NMCLI Connection Enp4s0 Modify Ipv4.methord manual ipv4.address "192.168.1.120/24" Ipv4.gateway "192.168.1.1" Ipv4.dns "2 23.5.5.5 "A configuration item with no subnet mask. Then, write a function that implements the mutual transformation of
In this paper, we describe a simple way to implement the subnet mask transformation in Python. Share to everyone for your reference, as follows:
In this implementation, the subnet mask length is converted to the specific subnet mask address:
def exchange_maskint (mask_int): bin_arr = [' 0 ' for I in range (+)]
This example describes a Python implementation method that calculates a network segment based on an IP address and subnet mask. Share to everyone for your reference. Specific as follows:
This code is tested in the Linux environment 2.6.6python version!
#!/usr/bin/env python#_*_encoding:utf-8_*_#input your IP address and netmask to figure out your network. #申明:
is realized by self-invocation to the correct network bit . -b = (A.split ('/') [0]). Split ('.') -A = B[0] +'.'+ b[1] +'.'+ b[2] +'.'+ str (int (b[-1])-1) +'/'+ A.split ('/') [-1] - Ipip (a) in - defMain (): to #The IP address and mask you need to know to enter the keyboard when executing the file +Inputip = Raw_input ('Please input IPaddress (example:192.168.1.1/24): \ n >>>') - Ipip (Inputip) the #ipip (' 10.10.10.1/30 ') #测试用例, in order
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.