# returns an array of 2*3 0-1 x=np.random.rand (2,3)# returns a 2*3 standard normal distribution X=NP.RANDOM.RANDN (2,3 # returns a random integer that is located in the half open interval [low, high], and the last parameter is size# build [2,10]
1. Multiple functions or class definitions in Python can be placed in a. py file as a module. In the. py file of the module, it is generally written if __name__ = = ' __mian__ ' is used to execute some functions in the module separately.2. Python
Condition test:An If condition test expressionDifferent types of comparisons: numbers: Comparing sizesString: Per-character comparison by ASCII code tableLists and tuples: Comparing the contents of each part from left to rightDictionaries: Comparing
Expressions and statements for Python:Expression: A sequence of one or more operands and 0 or more operators.Statement: The operation to be implemented.Declare variables, assignment statements, control statements, conditional statements .... The
S.find (Substring,[start[end]]) #可指范围查找子串, returns the index value, otherwise returns-1For example>>>b = ' ABCD '>>> b.find (' d ')3>>> b.find (' d ', 2,4)3>>> b.find (' d ', 3,4)3>>> b.find (' d ', 2, 3)-1Visible when the specified range is
Most complete Pycharm Tutorials (1)--Custom SkinsMost full Pycharm Tutorials (2)-code styleMost full Pycharm Tutorials (3)-code debugging, running1. Preparatory work(1) The Pycharm version is 3.4 or higher.(2) At least one Python interpreter has
The so-called list is like a container, you can add and remove things from the list, the list is mutable, but the tuple is immutable.#Coding=utf-8#List of additions and deletions to changeListman = ['Name=oliver','age=13','Sex=male']Print "Original
3.1 Assigning valuesThe assignment generates a reference to the object, not a copy of the object, and it can be recalled that the C + + overloaded operator return is a reference to the object.So python's variables are more like pointers to C.The
#!/usr/bin/env Python# Coding=utf-8__metaclass__ = TypeClass Person:def __init__ (self, name):Self.name = NamePrint Self #新增Print type (self) #新增other parts omitted. When initializing, you first run the constructor and print the new two. The result
First write a little put up, not complete, Monday to the company in the optimization bar.Here the user input is written to the file, using variables, this variable was studied overnight.F.write ('%s \ n% variable ') also unexpected variables are
What is a module:A module is a collection of functions.Modules are similar to Lego bricks, you use these modules to assemble a model, and then you can combine the modules with other modules into a new model.Types of modules:1. Built-in modules
Finish the test that started last night.Last pool.A, use the return result of the pool#Coding:utf-8ImportMultiprocessingImport Timedeffunc (msg):Print 'msg:', msg time.sleep (3) Print 'End' return ' Done', msgif __name__=='__main__': Pool=
2.1 Python Program StructurePython can be divided into modules, statements and objects, the program is composed of modules, the module contains statements, statements generated, processing objects.2.2 Why use built-in objectstend to be more
Random numbers in PythonModule: RandomFunction:Uniform: Random floating point number>>> print Random.uniform (0,100) 37.5204548309Randint: Random integer>>> print Random.randint (0,100) 4Randrange: Random Even>>> print Random.randrange (0,101,2)
1. IntroductionTo add error detection and exception handling to your code, you only need to encapsulate it in try-except.Try: The code to be managed laterExcept: Handling the wrong code2. ExampleImportOSTry: Path='E:'os.chdir (path) filename=
Here is a function can not be achieved, is to let people enter their own password, interactive. Incoming passwords come in instead of being defined here.Also hope pointing. Want to interact with Python here and let the user enter the MySQL
Using Linux epoll with Python
Transfer from http://scotdoyle.com/python-epoll-howto.html
import socket, selectEOL1 = b''EOL2 = b''response = b'HTTP/1.0 200 OKDate: Mon, 1 Jan 1996 01:01:01 GMT'response += b'Content-Type: text/plainContent-Length:
, 5th dayEssential knowledge of decorator
1. the decorator is defined by at least two layers of functions.
2. Dynamic Functions
3. function return value
4. Three-layer and above function-defined decorators
5. Multiple decorators
Implementation
A collection of basic python knowledge and a summary of basic python knowledge
Set
Feature: A collection object is a group of unordered hash values. A set Member can be used as a dictionary key. Unlike the list and metadata, a set cannot be indexed
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