This Learning note organizes the contents of list and tuple, conditional judgments and loops, dict and set, functions, slices, list generation, generator seven, and is very basic, but a bit trivial. Well, let's get started.(1) List and tupleOne of
The standard library contains several different types of libraries.The first is the data type library for those core languages, such as numbers and list-related libraries. The core language manual simply describes how numbers and lists are written,
Constructors in Python typically use two underscores before and after a constructor:There are parametric constructors:Overriding the general method:Special constructors (typically used for constructors to be overridden, but need to be constructors
Remember that there is also the concept of property in cocoa, the property in Python and the property in cocoa seems to be similar. Here are two ways to use it.Usage One:classTest (object):def __init__(self):Print "Init is calling"SELF.A=100defGetX (
Slicing the stringThe string ' xxx ' and the unicode string U ' xxx ' can also be viewed as a list, each element being a character. Therefore, a string can also be manipulated with a slice, but the result of the operation is still a string:>>> '
Contacted Ruby and found it has a package management tool Rubygem is very useful and has a very complete documentation system Http://rdoc.infoDiscovery Python also has the same tools, including Easy_install and Pip. Just, I did not examine the
Update setBecause set stores a set of unordered elements that are not duplicated , the update set mainly does two things:One is to add the new element to the set, and the other is to remove the existing element from the set.When adding an element,
Returns multiple valuesCan a function return multiple values? The answer is yes.For example, in the game often need to move from one point to another point, give the coordinates, displacements and angles, you can calculate the new coordinates:# The
Defining Default ParametersWhen defining a function, you can also have default parameters.For example, the python's own int () function, in fact, there are two parameters, we can both pass a parameter, and can pass two parameters:>>> Int (' 123 ') 12
Defining mutable parametersIf you want a function to accept any of the arguments, we can define a variable parameter:DEF fn (*args): print args#coding =gbkdef Kebian (*arg): Return Argprint (Kebian (1)) Print (Kebian (' Str ')) print (Kebian ([+)]
Import CollectionsPay attention to the counter when using the capital,Counter is about counting the number of occurrences of an object in a list and then returning it as a countersuch as
Original title address: https://oj.leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/Problem solving: The difference between this and the previous question is that the array may have the same number. Then, there are several
Python note files1. Open and create a file # file () is used for file (name, mode [, buffering]) in file management. The name is the file name, and the name contains-open; does not exist. The creation mode is the open mode, r, r +, w, w +, a, a +, B,
Python dictionary advanced usage SummaryPython dictionary advanced usage Summary
A dictionary is a flexible and powerful data structure in python that can perform many operations. This article summarizes some common dictionary usage methods except
I learned how to load Python modules and how to load python.
Whether it's using import or from mmmm import *, when the program runs, you can check the mmmm. directory of The py file (about mmmm. the py file can be viewed in the previous Lecture),
20 suggestions for Python performance optimization and 20 suggestions for python Performance OptimizationOptimize algorithm time complexity
The time complexity of the algorithm has the greatest impact on the execution efficiency of the program. In
Learn Python private functions and proprietary methods
In any language, certain objects (attributes, methods, functions, classes, etc.) can only be accessed within a certain range. This is a distinction between "public" and "private. In addition,
Python uses scapy to simulate packets to implement arp attacks and dns amplification attacks. For example, pythonscapy
Scapy is a powerful interactive data packet processing program written in python. It can be used to send, sniff, parse and forge
Manually publish a python project as an exe executable program.
1. manual preparation of the python exe executable program Python does not have an internal function to compile as exe. It brings a lot of trouble to the deployment of python programs.
Share the script for verifying IP address legality implemented by python and shell, pythonshell
I. Check IP address validity in python
Execution result:
Python code:
Copy codeThe Code is as follows:[Root @ yang python] # vi check_ip.py#!
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