Python (v)

Source: Internet
Author: User


@font-face {font-family: "Times New Roman";} @font-face {font-family: "Song Body";} P.msonormal {margin:0pt 0pt 0.0001pt; text-align:justify; font-family: ' Times New Roman '; font-size:10.5pt;} P.P {margin:5pt 0pt; text-align:left; font-family: ' Times New Roman '; font-size:12pt;} span.msoins {text-decoration:underline; color:blue;} Span.msodel {text-decoration:line-through; color:red;} Div. Section0 {page:section0;}

Array

Arrays Store A string of information of the same type

List

First, definition of a list

? Define an empty list

list = []

? Defines a list that contains elements that can be any type , including numeric types , lists , tuples , such as strings , etc. can be.

How to assign a value Definition:

List = ["Fentiao", 4, ' gender ')

List1 = [' Fentiao ', (4, ' Male ')]

Factory Functions Definition:

n = list ("Hello")

In [2]: n=list ("Hello")

In [3]: print n

[' H ', ' e ', ' l ', ' l ', ' O ']

Second, support indexing, slicing, splicing, repeating, member operators

indexes, slices:

In [4]: li=[1,1.0,true, ' hello ', 1+4j,[1,2, ' hello ']

In [5]: li[0]

OUT[5]: 1

In [6]: li[-1]

OUT[6]: [1, 2, ' hello ']

In [7]: li[:]

OUT[7]: [1, 1.0, True, ' Hello ', (1+4j), [1, 2, ' hello ']]

In [8]: li[1:]

OUT[8]: [1.0, True, ' Hello ', (1+4j), [1, 2, ' hello ']]

In [9]: li[0:2]

out[9]: [1, 1.0]

In [ten]: li[::-1]

out[]: [[1, 2, ' Hello '], (1+4j), ' Hello ', True, 1.0, 1]

Stitching:

In []: li1=[' vsftpd ', ' Apache ']

in [+]: li2=[' mariadb ', ' NFS ']

In []: Li1 + li2

OUT[20]: [' vsftpd ', ' Apache ', ' mariadb ', ' NFS ']

Repeat:

in [+]: li1=[' vsftpd ', ' Apache ']

In []: li1*2

OUT[22]: [' vsftpd ', ' Apache ', ' vsftpd ', ' Apache ']

Member operators:

In [23°c]: li1=[' vsftpd ', ' Apache ']

in [+]: ' vsftpd ' in Li1

OUT[24]: True

in [+]: ' vsftpd ' not in Li1

OUT[25]: False

Topic 1:

View the 21,22,3306,80,69 Port of the 1-10 host

Answer:

#!/usr/bin/env python
# Coding:utf-8
ports = [21,22,3306,80,69]
For i in range (1,11):
For port in ports:   # Each element in the list can be traversed by the for i in list
IP = ' 172.25.254. ' +str (i)
print "[+] Listening on:%s:%d"% (ip,port)

Three, the common method of the list

1. Update the list

Append ( add an element )

Extend ( You can add multiple elements , you can give a list in parentheses, and the elements in the list are poured into the original list and become his element )

@font-face {font-family: "Times New Roman";} @font-face {font-family: "Song Body";} P.msonormal {margin:0pt 0pt 0.0001pt; text-align:justify; font-family: ' Times New Roman '; font-size:10.5pt;} P.P {margin:5pt 0pt; text-align:left; font-family: ' Times New Roman '; font-size:12pt;} span.msoins {text-decoration:underline; color:blue;} Span.msodel {text-decoration:line-through; color:red;} Div. Section0 {page:section0;}


Python (v)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.