Python Basicsfirst, python data types1, int (integral Type)On a 32-bit machine, the number of integers is 32 bits, and the value range is -2**31~2**31-1, which is -2147483648~2147483647, and. on 64-bit systems, the number of integers is 64 bits and
Python learning notes (2) and python learning notesI. Basic list definition
A list is a sequential data type. You can use subscript to access an element or element in the list. It can save any number of Flexible containers of any object type.
alist =
Python list basic operationsRemember a word, called Gu head regardless of the tailLet's start by defining a listname = ["Jixuege", "Dajiba", "Boduoye", "Cangjinkong", "Youtianai"]Next, we'll do a series of operations on this list.1. SlicingTake the
The meaning of the occurrence of string dataMastering the definition and characteristics of stringsAbility to master string common operations and learn about other factory methodsDefinition and creation of stringsA string is an ordered set of
The list is one of the most commonly used data types in the future, with lists that allow the most convenient storage, modification, and so on for the data to be defined list 1 names = ['Alex','tenglan','Eric ']To access the elements in the list by
Online about the scope of Python introduction There are many, then the small part of today to share this article is to let everyone through the study of these 5 points of knowledge, you can easily fix the scope of Python, the need for friends can
Python scope, python
Before writing a scope, you must first understand the local variables and global variables. After understanding local variables and global variables, the concept of scope is well understood.
Local variable: Local variables can
Lists [list] use brackets [] to handle the data structure of a set of ordered items, the type of the list is a mutable data type, and the type is a listThe list is mutable/thread insecure
# type (a) = list uses the type to determine the
List of the increase, deletion, change, checkTuples are the system listList and STR can be converted to each other, split (), join ()Coding review:ASCII: Letters, numbers, special characters: 1 bytes, 8 bitsUnicode:16 bit two byte upgrade 32 bit
First, local variables and global variablesName= ' LHF ' global variablesDef change_name ():Global name globally variable without global is local variableName= ' Handsome a ratio 'Print (' Change_name ', name)Change_name ()Print (name)Name= ' LHF
First, bytes typeTwo or three-dollar operation
1
result = value 1 if condition else value 2
If the condition is true: result = value 1If the condition is false: result = value 2Third, the binary
Binary, 01
There are usually multiple characters in a string in Python, how do I intercept it?Example: name = ' My name is jockey 'We first numbered this string, starting with 0:1. Print a character>>> print (name[0])M>>> print (name[11])J2. Print one of the
1:3-dollar operation1 if Else 2The ternary operation first determines if the statement after the if is established, like the above code if A>0 is the result = 1, not the result = 2.Two: string and bytes convert each other1 " My name is Lei Feng " 2
Python list operation--IncreaseAppend: Append a piece of data to the end of the listname = ["Zhangsan","Xiongda","Lisi"]name.append ("Wangwu")Printname Output result: ['Zhangsan','Xiongda','Lisi','Wangwu']Insert : Inserts a single piece of data at
First, the basic definition of the listA list is a serialized data type that can be used to access an element or elements in a list. It can hold a very flexible container of any number, arbitrary object type.Alist = [123, 1.23, ' abc ', [1, a]]This
Windows wants to add environment variables.If the upgrade version of Linux is inconsistent,#!/usr/bin/env python calls the environment variable in python#!/usr/bin/python calling the default Python in the systemVariable definition rules:1. Variable
A. List 1. Define a listname=["Tom", "Jerry", "a", "a", "Lose", "Me"2. IndexAs with the index of a string, the list index starts at 0.Print ("First element:%s"%name[0]) >> first element: TomPrint ("Last element:%s"%name[-1])>> last element: Me3.
1. Yesterday's content reviewfunction: Avoid repeating code and enhance readability.Features: function-oriented.def function name ():function bodyreturn value of function: return1, the return End function is encountered in the function.2,return
Count ():Number of repetitions of elements in the statistics listname = ["1", "2", "2", "1"]print (Name.count ("1"))Len ():Even if the "Length"If you want to count the number of all elements in the list then the count () function will not work,
The data structure is divided into two parts:1, Single valueDigitalInteger: If it is a 32-bit machine, the number of digits of the integer is 32 bits, the value range is -2**32 ~2**31-1, namely: -2147483547~-2147483548If it is a 64-bit machine, the
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