Python Learning Summary

Source: Internet
Author: User

1 Learn What's the name of the course?

Python: Front-end first knowledge of HTML, background foundation flask

2 How to output a sentence, with code examples

Output by: Print

For example :

3 how to run with terminal tools Python Code

For example, I want to run the program of Topic 2, where is my py file dragged over to the back of the car?

The code is as follows:

python/users/mac/desktop/jaoany/1/print.py

4 in the Python What are the placeholders and what do they mean?

The% operator is the one used to format the string

Inside the string,%s means replacing with a string

%d = Replace with integer

%f Decimal

If there is only one%, the parentheses can be omitted.

5 in Python What are the data types inside, using variable examples

Data type:

1. String

2. Boolean type

3, Integer

4. Floating point number

5. Digital

6. List

7, meta-group

8. Dictionaries

9. Date

Example: printing multiple variables at the same time

num=10 #整数打印

Name= ' Laowang ' #字符串

res=1.1 #小数

Print Num,name,res

print ' num:%d '%num

6  What are the logical operators of Python and what are the functions?

operator logical Expression Description

and

X and Y

Boolean "and"-if x is False,x and y returns FALSE, otherwise it returns the computed value of Y.

(A and B) returns 20.

Or

X or Y

Boolean "or"-if X is non-0, it returns the value of x, otherwise it returns the computed value of Y.

(A or B) returns 10.

Not

Not X

Boolean "Non"-returns False if X is True. If X is False, it returns TRUE.

Not (A and B) returns False

7 What are the control statements

(1) Select structure If...else; or (If...elif...elif....else)

(2) loop for loop while loop

(3) nested for nested for,while nested while

(4) Break to terminate the loop

(5) Continue jump out of this cycle

(6) Pass empty statement

8 How about a random one - to the - the number

Allow it to support Chinese

#coding: Utf-8

Defining random numbers

Import Random

Num=random.randint (50,100)

Output to

print ' num ', num

9  The difference between range and xrange

Range: The description generates a sequence based on the specified range, along with the set step size

xrange function Description: The usage is exactly the same as range, the difference is not an array, but a builder.

Ten declares a two-dimensional array or List

# declares a variable, List type

L_list=[]

One how to read and write files

# W Write R read

# f Declare a file read/write Object

# If the file exists, re-write, if not present, write after creation

F=open (' Stu.txt ', ' W ')

F=open (' Stu.txt ', ' R ')

print ' File name: ', F.name

A Customize a function with two parameters with a return value, and call to view the results

#coding: Utf-8

#添加数据

def hello ():

print ' Hello! ‘

#保存数据

Def goodby ():

print ' Goodbye! ‘

While 1:

# num=input (' Please enter your actions: 1: Add data ' + ' \ n ' + ' 2: Delete data ' + ' \ n ' + ' 3: Update data ' + ' \ n ' + ' 4: View data ' + ' \ n ' + ' 5: Exit program ')

Num=input (' Please enter data 1 or 2: ')

If num==1:

Hello ()

Else

Goodby ()

Break

HTML is what

HTML (Hyper Text mark-up Language), or Hypertext Markup Language, is the description language of WWW, presented by Tim Berners-lee. The purpose of the HTML language is to make it easy to connect text or graphics stored on one computer with text or graphics from another computer to form an organic whole, regardless of whether the specific information is on the current computer or on other computers in the network. This way, if you use your mouse to pick an icon in a document, the Internet will go right away

To the content associated with this icon, and this information may be stored on another computer in the network.

HTML text is a descriptive text made up of HTML commands that describe text, graphics, animations, sounds, tables, links, and so on. The structure of HTML consists of two parts: Head (head), Body (body).

1 4 List your favorite tags.

Div

Span

Table

...

the a Div , set its CSS style, including size, border, color, etc.

div{

width:150px;

height:150px;

Background:green;

/* Cut rounded corners */

border-radius:60%;

/*div label distance from top of page */

margin-top:10px;

margin-right:200px;

margin-left:200px;

/* The setting of the inner margin of the DIV tag itself up or down around the change * *

padding-top:50px;

}

- List The positioning methods you know

1 , static ( default )

When you do not specify a positioning method for an element, such as a Div, the default is static,

2 , relative ( relative positioning )

3 , Absolute ( absolute positioning )

What is flask ?  

Flask is a web framework. This means that Flask provides you with tools, libraries, and techniques to allow you to build a Web application. This wdb application can make some Web pages, blogs, wikis, web-based calendar apps, or commercial web sites.

Flask belongs to the micro-framework (micro-framework) category, and microarchitecture is often a small framework that does not depend on external libraries. This has both advantages and disadvantages, the advantage is that the framework is lightweight, less dependent on updates, and focus on security bugs, the downside is that you have to do more work yourself, or add a plugin to increase their dependency list

- How to create Flask application, how to run

# Flask Constructor Creation

From flask import Flask

App=flask (__name__)

Run:

# win+b appears a URL http:/0.0.1:5000/copy to Browser view

+ How to use Flask get parameters passed by the client

# adorners, which are used to encapsulate links while returning data

@app. Route ('/')

def index ():

# decoration function

Return ' Hello flask! '

# Http://127.0.0.1:5000/home

@app. Route (' home ')

Def home ():

Return ' Welcome to my homepage! '

App.debug=true

# Run Server

App.run ()

- create a route to process the login logic

To jump to a new page:

3

Front:

Python Learning Summary

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.