Day2 Grasping Bag &python Foundation

Source: Internet
Author: User

Grab Bag:

Why to grab a bag:
1, positioning problems
2. Tampering Request
3, can test other anomalies of the system
Mobile Clutch Charles:

1, open Charles, must ensure that the mobile phone and the computer is in a LAN inside
2, mobile phone set agent, server write your computer's IP, port number default is 8888

HTTPS protocol can not fetch data, security protocol, it needs to import the corresponding company's own certificate into the Capture tool.

Analog weak-net test: Speed limit

To set the port:

SOUPUI:

1. Sopaui Create a new SOAP project
2. In the WSDL address here, fill in the address of the WSDL interface
3, the left is the requested data, the right is the returned data

Python Basics:

Quotes:

In Python, the single and double quotation marks can be represented as a string, and the single and double quotation marks can be nested with each other (double quotes inside the single quotation mark, single quotes inside the double quotation marks), but not cross-used.

Comments:

Single-line Comment: Use a # number to denote multiple lines of comment: three quotation marks, same as no single double quotes

Eg: "XXXX

Ddddddd

Eeeeeeee ' or

"" "dddddddddddddddddd

Oooooooooo

PPPPPPPPPP "" "

Formatting:

Method One: + stitching

Import datetime

Today=datetime.datetime.today () #获取今天日期

user= ' AA '

msg= "Welcome" +user+ "Come to my home!" "+" Today's date is "+today

Method Two:% placeholder (recommended method, does not account for memory)

Name= "Zhangsan"

Print ("Hello%s,nice to meet you!"%name)

Output: Hello Zhangsan,nice to meet you!

age=11

score=86.2656

Score=round (score,2) #保四舍五入, left 2 digits after the decimal point

Msg= ' percent of your age is%d, your score is%.3f '% (age,score) #想打印% to write two%, two% is 2 in multiples of 4

Print (msg)

The placeholder%s is a string of%d that is an integer%f is a decimal (the default decimal after 6 bits)%.2f represents a decimal after 2 decimal places and is automatically rounded up, noting that the dot number after% does not ignore

Method Three:

Do not know what type of printing can be used%r or%s

n=100

Print (' You print is%r '%n)

You print is 100

If condition judgment:

a=2

B=3

If a>b:

Print (' A Max ')

Else

Print (' B Max ')

Python does not use {} as other languages to represent the body of the statement, and through the indentation of the statement body, the indentation default is 4 spaces. The IF statement in Python is judged equal by the = = operator, using! = judgment is not equal. The contained relationship is represented by in and not.

hi= ' Hello World '

If ' Hello ' in hi:

Print (' contain ')

Else

Print (' Nott contain ')

The IF statement can be judged by a Boolean type:

A=true

If a:

Print (' A is true ')

Else

Print (' A is not true ')

Multiple if conditions determine:

results=72

If results >=90:

Print (' excellent ')

Elif Results >=70:

Print (' good ')

Elif Results >=60:

Print (' Pass ')

Else

Print (' fail ')

While loop: While loop, there must be a calculator to record the number of loops, which is repeated execution of the code in the loop body

Count=0

While count<10:

    Print (' Break point ')
Count+=1 #count =count+1

Import Random #导入random
Num=random.randint (1,100) #产生一个随机数
Count=0
While count<7:
Guess=input (' Please enter the number you guessed: ')
Guess=int (guess)
If Guess>num:
Print (' Big up ')
Continue
Elif Guess<num:
Print (' small ')
Continue #结束本次循环, start the next cycle.
else:
Print (' Kong's right ')
break# Immediate End Loop
Count+=1#count=count+1
else: #循环正常结束后, the else is executed
Print (' The number of games has been exhausted, please recharge ')



For loop: The For loop is more efficient than while loop, it is simpler and more flexible, does not need to define counters and is automatically counted.

For i in ' Hello World ':

Print (i)

H

E

L

L

O

W

O

R

L

D

You need to use the range () function if you need to cycle a certain number of times.

For I in range (5):

Print (i)

0

1

2

3

4

The range () function defaults to a zero-based loop that sets the starting position and step size, such as the odd number between printing 1-10:

For I in Range (1,10,2):

Print (i)

1

3

5

7

9

Range (Start,end[,step]): Start indicates the start position, end represents the ending position, and step represents the step. In Python2, Range () is a generator, and xrange () is an array whose performance is better than the former because it does not need to open up a large amount of memory space, but they use exactly the same. The range () in Python3 is the same as xrange () in Python2, which is an array.

Array: (list)

The array is denoted by square brackets ([]), each of which is separated by commas.

Age = #int

name = ' Small black, JJ, Liu Xin, xxxx ' #字符串

Score = 98.35 #float no double type in Python

Stus = [' JJ ', ' Liu Xin ', ' Dambao ']

print (Type (stus))
print (stus[0])
#增
stus.append (' fan ') #在列表末尾增加一个元素
stus.insert (0, ' Leilei ') #在指定位置添加一个元素
# Delete
Stus.pop (2) #删除指定位置的元素
stus.remove (' Leilei ') #删除指定的元素
del stus[3] #删除指定位置的元素
#改
stus[1]= ' Lao Wang ' #修改
#查
print (stus[-1]) #取值 subscript 1, take the last element
stus.clear () #清空整个list
Stus.append (' Lao Wang ')
Print (Stus.count (' Lao Wang ')) #统计这个元素在list里面出现了几次
count = Stus.count (' Lao Wang ')
print (count)
Print (Stus.index (' Old King ')) #返回这个元素第一次出现的下标, if this element does not exist in the list, it will error
print (Stus)
stus.reverse () #反转
print (Stus)
stus2 = [' Peak ', ' Xiao Wang ', ' Zhang Zhong Yi ']
stus.extend (STUS2) #把后面list里面的值, add to the first list
print (Stus)

stu3 = Stus+stus2 #合并两个list
print (STU3)

nums = [1,3,8,5,23,24,3,3462,12]
Nums.sort (reverse=true) #排序, the default is ascending
print (nums)

n = [a] #1维数组
n2= [[[+], [' hehe ']] #二维数组
my = [[1,2,3,4,5,6],[' name ', ' age ', ' sex ', ' haha ', [' xiaoming ', ' Little black ', ' Little White ']],890] #3维数组
print (my[1][4][0])
my[1][4].append (' Little Violet ')
my[1][2]= ' sex '
print (my)
print (my) #看变量的元素个数, length
#多维数组

username = input (' User: ')
count = Stus.count (username)
# Print (stus)
# if count>0:
# print (' The user already exists ')
if username not in Stus:
print (' not present ')

Other:

a=11

Print (Type (a)) #判断常量类型

Type casts:

Name=input (' Please enter name: ')

Age=input (' Please enter Age: ') #input输入的都是字符串类型

Age=int (age) forced conversion to integer

a=11

A=STR (a) forced conversion to a string

score = 98.52699

Socre = Round (score,2) #四舍五入保留小数点后2位

Input () in Input:python2 requires the user to enter a string that must be quoted, in order to avoid some dangerous behavior when reading an illegal string type, and to use Raw_input () instead of input ().

quickly copy one line of code:ctr+d

Python2 Code has a Chinese error: write the following line of code in the first line of code.

#-*-Coding:utf-8-*

To set the Python version type:

Day2 Grasping Bag &python Foundation

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.