Python installation Jieba Chinese sub-phrases1. Download http://pypi.python.org/pypi/jieba/2. Unzip to the Python directory:3, "Win+r" into the cmd; Enter the following code, in turn:C:\USERS\ADMINISTRATOR>CD
Topics discussed in this chapterHow Python calculates adorner syntaxHow Python determines if a variable is not local (by assigning a value to a variable inside a function to determine if it is a local variable)Reasons for closures and how they work (
Variable is not a boxChoose between = = and is= = compares the values of two objects, while the is comparison object's identityRelative immutable surname of tuplesTuples, like most Python collections (lists, dictionaries, sets, and so on), hold
__doc__
Used to represent descriptive information for a class#-*-Coding:utf-8-*-__author__ = "MuT6 Sch01ar" class Person (object): " This class is used to describe the" def __init__ (self,name , age): self.name = name
In Python, you can simplify multiple lines of code into one line, with the For loop and if condition judgments all in one line, as shown in the following example:>>> fromNltk.corpusImportStopwords>>> english_stopwords = Stopwords.words ('中文版')
An immutable sequence of tuple tuples. Contains arbitrary objects. can be nested arbitrarily. Accessed through the following table. No support for in-situ changesImmutable refers to not supporting in-situ changes, nor appending elements and
SocketAn interface between the application layer and the TCP,UCP protocol, the user only needs to operate the interface, and the complex data organization work is done internally by itself.Socket (socket) for TCP protocol:Service
One, List analytic typeList parsing is a pair of brackets outside, which returns a list.The general form is: [Expr for item ' in itratoble]Print ([i+1 for I in Range]) #结果: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]DEF Inc (X): return X**2print ([Inc (I)
Read and write filesif __name__==‘__main__‘: filename=input(‘请输入保存的文件:‘) fdfile=open(filename,‘w+‘) while 1: text=input(‘请输入内容: ‘) if text == ‘EOF‘: break else: fdfile.write(text) fdfile.
1 Array objectsCreate an arrayImport= Np.arange (2,10) step is 1#[0,10] A total of 20 # Creating an array with List/tupleFast generation of X*y full zero groupsA = Np.zeros ((3,4))Random number of 0~1A = Np.random.rand (5)Converting one-dimensional
The software that installs ArcGIS (ArcMap, ArcGIS Server, and so on) automatically installs a Python environment in which we can use ArcGIS's arcpy library to work with the various functions of data in ArcGIS.But we can't use arcpy when we follow
1 selectionIf elif ElseNote that the following are:if age>18: print'adult'elif age>6: Print ' teenager ' Else : Print ' Kid '2 Cycles1) for x in XX:names = ['Michael'Bob'Tracy ' ] for in names: Print name2) while XX:sum == while n > 0:
Python Simple data type
Listlist creation, using []A_list = [' A ', ' B ', ' C ']Print A_listPrint A_list[0] #aIf you go to the last element of the list, in addition to calculating the index location, you can also use-1Print A_list[-1] #cAnd so
1.name = "Alex"Print (ID (name))Li = [a]Print (ID (LI))2.is determines the memory addressName1 ="[email protected]"name2="[email protected]"Print(name1 = =name2)Print(name1 isname2)in Pycharm, 2 of the results are true .in the Python small black box,
Get Request:Usage Scenario: If you only get data for the server and do not have any impact on the server, then use a GET request at this time . parameter:The Get request is placed in the URL , and is passed '? ' To specify key and value in the form
Select Sort:First, the language description: From a list of numbers in turn select the smallest place, the second bit small, and so on to complete the sorting
First traversal, find the smallest number, put it in the first position
#用户输入A = input (' Please input: ') #这个输入什么即是什么, such as enter 1, then a variable = 1, enter ' ABC ', then a variable = ' abc ', input ABC is error, because it will be a variable, and there is no ABC this variablePrint a #结果是输入的结果A = raw_input ('
Python built-in functions
# Continuous updates. If any leakage occurs, add
# There are not many gossip sessions. Go directly to case
A = ['A', 'B', 'C', 'D', 'E']
B = 'abcde'
C = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5}
Len (a) # The length of
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