First of all we need to know that the so-called automated testing is to use code to help us achieve point and call interface, saving their time, improve the efficiency of testing,
As automation we have to learn a language to be tall, we touch the language from the beginning of Python, the first computer only know 0 and 1 of the binary, the computer to run the code, the first computer will have a compiler to write our code into binary files, the computer knows the language we write, Language is divided into two languages
A compiled language, written code will be compiled into a binary language, run the time to run the compiled binary files
Compiled languages are: C C + + C #
Interpreted language
Run a line of code to compile a line, when to run the code, when to compile the code, to explain that the line language runs faster without compiling the line language
Explanation Line language has php python ruby Java
For example, you read a language book is a compilation language, you ask a translator is an explanatory language
Compile language is fast, but the compilation process is slow
Explanatory language is slow and the compilation process is fast
There is also a scripting language: definition is a language with a single function
such as the Linux command HTML
First Python basic commands we want to know quick Comment Ctrl +/
The first step to learning is to know that defining variables like Liu Wei = ugly is a defined variable such as liuwei= "ugly" which is the definition of a variable.
Liuwei is a variable, inside what you want to save something, all the programming is to deal with memory, when we define the variable will be in memory to generate a memory space, the space is stored in the ugly
When we write the code, we have to use symbols that are in English, and note that if you enter let ' go in Python,
At this point, if it's a single quote, we're going to use double quotes outside.
A comment paragraph can also be wrapped in three quotes with ' content ' as a multiline comment.
When defining a variable, if we define an integer, we can use no quotes like Dong Chunguang =29, which is an integer type.
If we want to see what type of statement that line is, you can use this method of print (type age) to see the type of the variable you're defining, the string is of type string, and the decimal point is the float type
Note (try not to take the Chinese name when naming the word)
Judgment: Python's judgment is in the form of IFL, which is written as
If age>18: (= = equals to write, must be preceded by a colon, add the next line of colon must be indented, indentation can be performed with the TAB key, usually four spaces and a key)
Print ("adult")
Else
Print ("not adult")
Representative now a total of two roads, or take this one, or go that one,
The accepted input format is age=input ("Please enter your name") input is an input to receive the variable age, only if you write input, you can enter the content, input receives the type by default
String string type, sometimes requires conversion type, the conversion type is age=int (age),
The difference between and and or, and is both must be satisfied, or is two kinds of satisfying one can
Determine if the basic format if:
Print ()
Elif
Print ()
Else
equals a bit a==b, so a!=b, all the code is running code from the go,
Print ()
If we want to call a module between 1-10 to select a number, remember a dead command:
Import Random
Num=random.randint (1.10)
The so-called loop is the repetition of one thing, the loops you see, the iterations, the loops that are worth the loop. There are two kinds of loops in the python, for and while forms
First, when using a while loop, you must first define a counter such as
Count=0 This is the meaning of the definition counter.
While count<10:
Print ("Kawaii")
This cycle is a dead loop, because his results have been less than 10, and want to release the cycle of the cycle will be in the loop, plus count+1=0 is count=count+1
Count=0
While count<10:
Print ("Kawaii")
Count=count+1
The thing under the colon is the loop body, the loop repeats the loop body, the inside thing, and in the loop body there will be break and continue,break meaning, when your loop encounters a break, will jump out of the loop body stop running, and coutinue, the meaning is, Jump out of this loop and continue to the next loop
Python will have string formatting in the form, our best way is if you want to define a time string
For example
Username=input ("Please enter the name") first define a variable, give him an output position
Welcome= ' Welcome:%s '%username
%s placeholder for the top username in one place
Import datetime
Today=datetime.data.today () This command is the statement that invokes today's current time
Username=input ("Please enter the name")
Welcome= ' welcome:%s, today's date is:%s '% (username,today)
In that case, we implemented a simple string formatting function.
%s means string%d for integer
About Python Automation (first section)