Python provides some interesting and useful functions, such as any all zip, which greatly simplifies our code and can handle iterative objects more gracefully, while at the same time we need to be aware of some situations any
any(
int (x [,base ]) converts x to an integer long (x [,base ]) convert x to a long integer float (x ) convert x to a floating point number Complex (real [,imag ]) Create a complex str (x )
1. the two ways of the Hello World programExecute under Windows1. Input in editor without compilingprint ("Hello world!") can be run directly2, can be saved into a program and then run
saved as a text, Create a new. py file. Execute in CMD
Input and outputPrint () Adds a string to the parentheses to output the specified text to the screen.>>>print ('helloWorld')Hello Worldprint()A function can also accept multiple strings, separated by a comma "," and can be connected to a string of
python1.GILGlobal interpretation Lock (only one kernel, thread damage, all bad)2. Strong type For example, do not want to add different types of designation, will be directly error.3. Object-oriented4. Functional typeMulti-process way to improve
Print "Enter your name",Somename=raw_input ()Print SomenameThe result is the following print "Enter your name" followed by a comma "," the input will be displayed on the same linePython 2.7.6 (default, Nov, 19:24:24) [MSC v.1500-bit (AMD64)] on Win32
In addition to the built-in modules, Python also has a large number of third-party modules.Basically, all third-party modules are registered on the Https://pypi.python.org/pypi, and can be installed with PIP as long as the corresponding module name
How to achieve rounding (not rounding down) under python2.7Thought for a long while did not want to come out, later Baidu a bit.Basically is the original number +0.5, or the use of the original downward rounding mechanismIf the original is If the
python format substitution and meaning of the string
Symbol
Description
%c
Formatting characters and their ASCII code
%s
formatting strings
%d
formatting integers
Tuples: In pairs of parentheses, can not be added or deleted, can only be viewed.Dictionary: In a pair of curly braces, the dictionary contains key and value, and the dictionary is unordered.Here are some common operations for dictionaries and
First, the Environment preparation1. Download the Python installation package (to the official website)https://www.python.org/downloads/Recommended download Install the latest version2. Set "Environment variables"My Computer---Properties----advanced-
1, the Python program deployment to the SAE need to make changesRun Python programs on-line that need to be converted into WSGI.Running a python program in the SAE requires specifying a function as an entry function.Application = Sae.create_wsgi_app
List attributes: lists are generated onceA = [1,2,3,4,5,6,7,8,9]Or[i*2 for I in range] # # #---> list generation===[2,4,6,8,10,12,14,16,18,20]===Two List of differences:1 list is written dead, 2 list can do some operations inside to output the
Create a project with django and create a project with django
First, you have to install python and django, and then configure the environment variables. If you do not install python, you should start from configuring the environment variables.
1.
Sublime Text3 is configured to run the python shortcut key in an interactive environment. sublimepythonInstall plug-ins
It feels good to write code under Sublime Text3, But I encountered some problems when writing Python.Use Sublime Text3 to open
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