0String: "This is a string"5 Complex data typesThe complex data types in Python are:List: li=[1,2,3,4,]Tuple Ganso: t1= (1,2,3,4)Dict dictionary: dic={' K1 ': ' v1 ', ' K2 ', ' v2 '}6 Basic Process ControlIf.. else/if. Elif. else used to select the control flowFor,while loops to control loops7 Variables and constantsConstants are generally expressed in uppercase letters to differentiate variables such as pi=3.148 IndentPython needs to be indented to
The first week of Python automation development and learning, and the first week of python Automation
1. Development History of python
2. What language is python?Compiled or interpreted? Python is an interpreted language.
Advantag
objects will be recycled as soon as they are no longer referenced. For those that are not recycled, the buffering mechanism has nothing to do with the code.Judging if they are equal>>> l=[1,2,3]>>> m=l>>> l==mTrue>>> L is MTrue= = Checks if the object has the same value. Is operator to check the identity of the object. If two variable names point precisely to the same object, it returns True. So this is a more rigorous equivalence test.It is, in fact, just a pointer to a realistic reference. So
can print (GetAttr (S1, ' Set_score ', ' No method ') # Gets the method name, if you want to execute the method, call it directly # setattr:# modify the value of a property setattr (S1, ' name ', ' Westos ') print (GetAttr (S1, ' name ')) # Add a property and The corresponding value; SetAttr (S1, ' score ', ") Print (GetAttr (S1, ' score ') # Modify Method Def get_score1 (): Return "This is the method content of the modification" setattr (S1, ' Get_score ', get_score1) print (GetAttr (S1, ' Get
the code. The code in the book is a gradual progression from less to more. For each of the books (is every OH) routine, to be able to start from beginning to end every word of each of the keywords are understood what the meaning (the book clearly pointed out that do not understand the neglect of). Then close the book and write the code that will enable the same functionality. At the same time, appropriate changes to the code, such as the deletion of a piece, plus a sentence or something, to dee
() ' SPAM 'Ordinary strings converted to Unicode stringsIf you concatenate a normal string with a Unicode string, Python automatically converts the normal string to a Unicode string before the connection operation.>>> ' Hello ' + u ' + ' world ' +u '! ' U ' Hello world! '3. Operators that apply only to stringsFormatting operatorsPython-style string formatting operators, only for string types, very similar to the C language inside the printf function
Python learning day 2, python Day 2
Memory address query for python Variables
#!/usr/bin/env python# -*- coding:utf-8 -*-name = "zhang"name1 = "frank"id (name)
Process Control and indentation
If condition:
Execute the next statement (content)
Content 2
Else:
Content 3
Python multithreading learning and python Multithreading
I. Usage of threads in Python:
In Python, there are two ways to use threads: functions or classes to wrap thread objects.
1. Functional Method: Call start_new_thread () function in the thread module to generate a new t
:
Slower running speed
Code cannot be encrypted
Threads cannot use multi-CPU, that is, the multi-core advantage cannot be exploited
code file format: xxx.pyPython interpreter:
CPython: The most widely used interpreter
IPython
PyPy: Fast, using JIT to dynamically compile Python
Jython
IronPython
Python developed from 2 to 3 the most important changes: 3 Uni
library that parse the command line. NetworkOne of the big applications of Python is in the web. But Python and the standard library simply provide interfaces and do not involve the underlying. Network knowledge can greatly reduce the steepness of learning curve.1) A layered architecture based on TCP/IP. This content
Make clean (clears the ". O" file) from the last make command and the executable file) 5 make Distclean (similar to do clean, but also delete all configure generated files, including makefile)Note: You can actually make Distclean directly without performing a 4th step4)/usr/local/bin/python2.7-v (view version information) View System Python version/usr/bin/python-v 5) Modify the original
valuesMy_dict.clear () Empty dictionarySeven. Collection(1) Unordered non-repeating element (key) set; similar to dictionary, but without "value"Created: X=set ()X={key1,key2,...}Add and remove X.add (' body ')X.remove (' body ')Operators for Collections:- | ! =(2) The set principle is the same as the dict, so it is also not possible to put mutable objects, because it is not possible to determine whether two mutable objects are equal, and there is no guarantee that the set will "have no duplic
Python can be used in many ways as a common language:Web Application Development : Server-side programming, with a rich web development framework, such as Django and TurboGears, to quickly complete a Web site development and Web services. Typical such as the domestic watercress, shell nets, such as Google, Dropbox, etc.; System network Operation : operation and maintenance work, there are a lot of repetitive work place, and need to do the management s
, key is a list, error List is not hash7 Traceback (most recent):8File"", Line 1,inch9Typeerror:unhashable Type:'List' #list is non-hashedTen>>>Conversion between a collection and a listSet () List ()1>>> lst=[1,2,3]2>>> s =Set (LST) #将列表转换成集合3>>>s4Set ([1, 2, 3])5>>> Lst2 =list (s) #将集合转换为列表6>>>Lst27[1, 2, 3]8>>> a =[1,2,2,3,3,6,6,8,9, 0,0] #去除列表中的重复项, set () can be used9>>> s =set (a)Ten>>>s OneSet ([0, 1, 2, 3, 6, 8, 9]) A>>> A =List (s) #去除重复后, and then convert to lists ->>>a -[0, 1, 2, 3, 6
...)3.1.4. ListsThe sequence as one of the basic Python formats is fantastic. Here are some simple examples of how to use the list.Defining a sequence that looks a bit complicated is actually not complicated.LST = [0, 1, 2, 3, 4, 5, ' A ', ' B ', [8, 888], ' 9 ', {' 10 ': 10, 10:100}]LST[1] # 11 integersLST[8] # [8, 888] a sequenceLST[9] # ' 9 ' a stringLST[10] # {' 10 ': 10, 10:100} A dictionaryIt seems to be very flexible, it is so capricious.Slice
Basic Learning notes for exception handling and Python learning notes
An exception is an action taken outside the normal control flow due to a program error. The action is divided into two phases. The first stage is an error that causes an exception. When the system detects an error and is aware of the exception condition, the interpreter (or a programmer can ca
Object-oriented python learning [entry], python object-oriented
Preface
Recently, I have been studying Python object-oriented programming. I have never been familiar with other object-oriented programming languages before. Therefore, learning this part is quite exciting. I w
Learning a language is a constant practice, Python is currently used for data analysis of the most popular language, I recently bought a book "Data analysis Using Python" (Wes McKinney), but also to the library to borrow this "Python Data analysis Basic Tutorial--numpy study Guide" (second edition), ready to the
I was reading a senior student, a small white one, want to learn artificial intelligence. I will share what I have learned every day, and hope that those with whom I like to learn and communicate with each other.So let's start with Python. The first time to write a blog, the heart is a little excited. Hee Hee This tutorial is very simple and can be skipped directly if there is a programming basis for the person. I mainly think of nothing to unde
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.