clay figurine to blow the tone will become a person! ")#create_people ()defWater (FN):definner ():Print("watering first .") fn ()Print("Fertilization") returnInner#func = water (create_people)#func ()Create_people = Water (create_people)#function names, like variable names, can be assigned to other variablesCreate_people ()Version with a syntactic sugar@waterdefcreate_people ():Print("Nu wa is very powerful, pinch a clay figurine to blow the tone will become a person! ")#create_people ()defW
Python Foundation OneFirst, Python historyThe founder of Python is Guido van Rossum (Guido van Rossum). 1989 Christmas period, Guido van Rossum (Chinese name: Uncle Turtle) in order to pass time in Amsterdam, determined to develop a new script interpreter, as an inheritance of the ABC language.(Uncle Tortoise: 2005 joi
) print (dic[' name ') dic={' name ': ' Yanglei ', ' Age ': 23}json.dump (' Dic,open (' B.json ', ' W ')) Print (Json.load (open (' B.json ', ' r ')) [' name ']) with open (' C.json ', ' R ') as F: Data=f.read () #[ null,true,false,1] eval (data)(2) PickleValid only for Python#!/usr/binl/env python#encoding:utf-8#author:yangleiimport pickledic={' name ': ' Yanglei ', ' Age ': 23}print ( Pickle.d
English and European languages; it can only be represented by a maximum of 8 bits (one byte), that is: 2**8 = 256, so the ASCII code can represent up to 256 symbols.
Unicode code: Also known as the Universal Code, the purpose is to solve the limitations of the traditional character encoding scheme, which sets a uniform and unique binary encoding for each character in each language, which specifies that although some characters and symbols are represented by at least 16 bits (2 bytes), tha
tuples.To define a tuple:A = (' 1 ', ' 2 ', ' 3 ', [' s ', ' B '])To change the elements of a list in a tuple:A[3][0] = ABCValue:Print (A[0])Cycle:t = (' A ', 1, ' B ', 1, (3,4))n = 0While n Print (T[n])n + = 1For I in range (len (t)):Print (T[i])Common operations for tuples:Count:t = (' A ', 1, ' B ', 1, (3,4))Print (T.count (1))D:\Python\Python36-32\python.exe e:/python/123. py2Process finished with exit
, namely:Import Getpass # Assigns user input to the name variable pwd = getpass.getpass ("Please enter password:") # Print the input contents of the printer (PWD)Python basic syntaxAn expression if: ElseName = input ("Please enter user name")PWD = Int (input ("Please enter password"))If name = = "Chendz" and pwd = = 123: Print ("Login Successful")elif name = = "or pwd = =" ": Print ("User name and password cannot be an empty string")Else Pr
;>> a=1 >>> ID (a) 1379185728 >>> b=1 >>> ID (b) 1379185728 variable occupied memory space comparison Small, no longer open up memory space, will be directly referenced, if the memory occupied by large, that the process of referencing will open up new memory space, which is a python optimization mechanism copy code >>> a= "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ">>> ID (a) 2884867588
no longer run on Py3. to take care of the earlier version, roll out the transition version 2.6 -- Basic use of Python 2.x syntax and libraries , taking into account the migration to Python 3.0, allowing the use of some of the Python 3.0 syntax and functions. the release of compatible version 2.7 has continued , A large number of Python3 features have been reve
indentation, and empty lines are not part of the Python syntax. When you write without inserting a blank line, the Python interpreter runs without errors. However, the purpose of a blank line is to separate the code of two different functions or meanings, which facilitates the maintenance or refactoring of future code.Show multiple statements on the same linePython can use multiple statements in the same r
, not a program to be executed, auxiliary instructions# This is the first one-line comment print ("Hello python")To ensure the readability of your code, it is recommended that you add a space before you write the appropriate explanatory textAdd a single line comment after the code
In program development, you can use # to add descriptive text behind (next to) the code
However, it is important to note that there are at least two spaces betw
1 )2 >>> a,rest,b3 (0, [1, 2, 3], 4)4 Pythonthe pros and consSee the pros first
Python's positioning is "elegant", "clear", "simple", so the Python program looks always easy to understand, beginners learn python, not only easy to get started, but also in the future, you can write those very very complex programs.
Development efficiency is very high, Pytho
Python I think a lot of people know. Now it is very fire, more and more people want to learn python, then 0 basic small white how to learn it? Today we recommend from zero to the project actual combat books! PDF documents I have, the paper is not shared to everyone, if you want to come to the group to find me!Introductory series"Python programming: Getting Starte
) = = Suiji:print "OK"Print SuijiBreakElif num > Suiji:Print "Xiao Xiao Xiao"Print SuijiContinueElif Num Print "Dadada"Print SuijiContinue5.Python Basic data typesSeveral data types built into Python are: lists, tuples, dictionaries, strings, numbers, character points, etc.6.Python Several modes of open fileR Read modeW Write modeA append modeA + w+ r+7.
/examples:function views 1. ADD an import:from My_app import views 2. Add a URL to Urlpatterns:url (R ' ^$ ', views.home, Name= ' home ") class-based views 1. ADD an import:from other_app.views import Home 2. Add a URL to Urlpatterns:url (R ' ^$ ', Home.as_view (), name= ' Home ') including another URLconf 1. Import the Include () function:from django.conf.urls import URL, include 2. Add a URL to Urlpatterns:url (R ' ^blog/', include (' Blog.urls '))""" fromDjango.conf.urlsImportURL fromDjango.c
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.