#! /usr/bin/python#Coding=utf-8From datetimeImportDatetime,timedelta"""Timedelta represents a time difference between two datetime"""now =DateTime.Now () past = past = DateTime (2010,11,12,13,14,15,16) TimeSpan = Now-Past#This will get a negative
One, for loopThe For loop is a very common loop in our programming, and here are some examples of applications for loops in Python:1. Single-layer for loop#!/usr/bin/env Python3#-*-Coding:utf-8-*-#user: Slim_liuFor I in range: #循环10次Print (i)
Rui LLinks: https://www.zhihu.com/question/21572891/answer/26046582Source: KnowCopyright belongs to the author, please contact the author for authorization.This is a rage to answer.You should've used IPython, right? Imagine, would it be nice to
1. Set operation : Remove weight{1, 2, 3, 4, 5, 6, 7, 8, 9}1 list1 = [1,2,3,4,5,5,6,7,8,9]2 list1 = Set (list1)3print( LIST1)View Code1.1There is a intersection in the collection syntax to ask for the intersection of two sets1List1 = [1,2,3,4,5,5,6,7
English documents:
hasattr
(object, name)
The arguments is an object and a string.
TrueThe result is if the string is the name of the one of the object ' s attributes, and
False if not. (This was
1 First of all must be installed Caffe, and compile the Python interface, if it is on Windows, it is best to copy the compiled Python folder Caffe folder under the Anaconda folder, so there is the code automatically prompt function, as follows:The
Integer and Boolean type
Gets the data type of the object
1. Type ()
2. Dir ()
3. Help ()
4, in the pycharm inside the operation
numeric type int
Create:
Int ()
Use Python to test the availability of a set of URLs in bulk (which can include HTTP status, response time, and so on) and count the number and frequency of unavailable situations.Similarly, such a script can determine the availability of a service
This script can be used to count the number of connected IPs on a port, and to count all IPs connected to that end, the maximum number of IPs and times, and the status of the TCP connection.Involves Python reading network connection statistics and
In object-oriented programming, exposed data members can be freely accessed and modified externally, which makes it difficult to control the legality of user's modification of the newly-updated data. A common way to solve this problem is to define
Python's Calling functionPython has built in a lot of useful functions that we can call directly.To invoke a function, you need to know the name and parameters of the function , such as an absolute function abs, which receives a parameter.
Note: Writing programs cannot write repetitive code learning content: Data type, for loop, while loop, character encoding, file processing one, for loop 1, simple for loop for I in range (10): # Here's what it means: a set of data within a loop
English documents:
Help ([Object])
Invoke the built-in Help system. (This function is intended-interactive use.) If no argument is given, the interactive Help system starts on the interpreter console. If The argument is a string and then the string
1. Functional Programming1) conceptFunctional programming is a programming model that considers computer operations to be calculations of functions in mathematics and avoids the concept of state and Variable. WikiWe know that object is the first
The dictionary is the only type of mapping in python, its hash value (key Key) and the point to object (value) is a one-to-many relationship;A dictionary is a mutable object, is a container type, can store any number, any type of mapping type, and
Python built-in functions (24) -- frozenset, pythonfrozenset
English document:
Class
frozenset([
Iterable])
Return a new
frozensetObject, optionally with elements taken from
Iterable.
frozensetIs a built-in class. See
Python built-in functions (23) -- format, pythonformat
English document:
format(Value[,Format_spec])
ConvertValueTo a "formatted" representation, as controlledFormat_spec. The interpretationFormat_specWill depend on the type ofValueArgument, however
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