if StatementNote: The contents of the statement block are forced to indent, otherwise an error occurs. Indentationerror, indentation ErrorAll code, if it is top-level, must be shelf written, cannot have spaces in frontIf ...:...Elif ...:...Else...
Differentiate by number of stored values
Scalar/Atomic Type
Number, string
Container type
list, tuple, dictionary
By Variable immutable distinction
Variable
List, dictionary
Objective. In Python, a dictionary is a series of key-value pairs, a mutable container that can store arbitrary objects, also known as associative arrays or hash tables.1. Basic syntaxUsing a series of key-value pairs in a pair of curly braces {},
Dictionary sorting is a common method in Python and is summarized here.Key sorting{1: ' A ', 2: ' B ', 3: ' C ', 4: ' d '}>>> key_sort=sorted (Test_dict.iteritems (), Key=lambda key:key[0], reverse = False ) >>> key_sort[(1, ' a '), (2, ' B '), (3, '
Formal parameters: When defining a function, the parameter inside the parentheses becomes the formal parameterFeature: parameter is variable namedef foo (x, y): #x =1,y=2Print (x)Print (y)Arguments: When a function is called, the argument inside the
One, character encodingCharacter encoding: translates human characters into numbers that a computer can recognize.Character encoding table: a table of characters that correspond to numbers.For example: ASCII, GBK, Utf-8, UnicodeUnicode----> Encode ('
First, call the procedure:1 Find First Name2 calling code by name The return value of a function has several ways:0->none (default)1-> returns 1 valuesMore than one tupleReturn value Note: Return value does not have a type limit1. No return: Return
Chapter III Using Strings3.1 Basic string manipulationSequence Operations (index, Shard, multiply, Judge membership, length, maximum, minimum) apply to a string, but the string is immutable, so the Shard assignment is illegal.3.2 String Formatting:
Character encoding:Translate human characters into numbers that computers can recognizeCharacter encoding tableA table of correspondence between human characters and computer numbersASCII, GBK, Utf-8, UnicodeUnicode "encode (UTF8)" bytesBytes
Requirements:
Enter user name and password
Successful authentication, display welcome information
User Name 3 input error, exit the program
Password 3 input error, lock user name
Readme:
UserList.txt is the file
Getting Started lesson one: a simple user interaction program1 name = input ("") #python3.x in replaces the Input_raw in python2.x 2 age = Int (input (#此处若不加int语句:)) , the computer is recognized as a string when entered, and in order to
Tag: End rod Ends Shopping cart budget number established choice COFFTarget Requirements:1. User Input Shopping Budget2, print the product list, by the user choice, budget enough to buy, not enough to prompt3. Enter Q to exit the program4, shopping
Classes and objects:To define a class:Class Name:PropertyMethodTo define the object of the class:Object name of class = Class name ()Class Property: Public and private, similar to C + + private and common, with the name of the variable added in
First, install the Python3Terminal input in Ubuntu: sudo apt-get install Python3Prompted that the resource is locked, there may be another program that is consuming this resource.Workaround: Enter the following command to unlock the resourcesudo
Login module:
Whether we go to that site, often encountered such a situation, let us log on to this site, the flowchart is as follows:
Ideas:
1. When we login to the site, we will first enter the user name, this time, some websites will remind us
This article mainly introduced the Python programming sequence operation, combined with the example form analysis Python sequence function, the correlation function and the concrete use skill, the need friend can refer to the next
The examples in
The adorner itself is a Python function that allows other functions to add extra functionality without any code changes, and the return value of the adorner is an additional object.
Let's look at a few definitions:
1, function
In Python, functions
First, define a class
Class Dog: # defines class def __init__ (self, name): # Constructor, constructor method = = Initialization method Self.name = name # D.name = attribute of the name class/member variable def say_hi (self): #
#1. The following program is a small part of the beginning of a TensorFlow neural network code to illustrate how to simply do the TF version compatibility and how to ignore compilation errors in Pydev to run
#2. Because the TF version is not yet
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