Len () is used to obtain values such as length, byte, etc.1 a = ["hello""World""dlrb" ]2 b = len (a)3 for in range (0, b): 4 Print (c, A[c])Output Result:0 Hello1 World 2 DLRBWe define the set a, which is given by Len to the number of elements
Special methodsSpecial methods exist to be called to the Python interpreter, and usually do not need to call them directly.This means that my_object.__len__ () should not be used, but should be called with Len (My_object).When executing len
A mechanism that loops one side of a loop in Python as a generator (generator)Executes at each invocation next() , yield encounters a statement return, and resumes execution from the last statement returned yield .Generate list for in range ()>>>1
1, in high-level language is usually built-in a set try...except...finally... of error handling mechanism, Python is no exception. We think that some code may be wrong, you can try run the code, if the execution of an error, the subsequent code will
Hello world!
Simple Interactive (interactive, file-style) textbook P19
The user enters two numbers and calculates and outputs the sum of two digits:
The user enters the triangular three-side length and calculates the area of the triangle:
I. Two methods of INTA__ADD__ ()Bit_length ()Number_one = 7Number_two = 5Print (Number_one + number_two)Print (number_one.__add__ (number_two))Print (Number_one.bit_length ())Print (Number_two.bit_length ())Effect:121233Second, string index and
Description: DateTime is a combination of date and time, containing all the information of dateCommon Uses for datetime:1, Datetime.datetime.now () returns a DateTime object of UTC time>>> from datetime import *>>> Print DateTime.Now ()2017-09-05 16:
1.1 Variable CommandNUMS_OF_GF = 19NUMSOFALEXGF = 19No, NAME-OF-ALEX-GF =19.The middle cannot have a minus sign, a spaceNumbers, special characters do not startKeyword cannot define a variableCan only start with a letter and an underscore 1.2
Data type ' "" There is no difference inside can add text # integer number: integer number # can be expressed as: Age ID number, telephone, QQ number age=10user_id=12321313213231231232131qq=666666666# String type: As long as the quotation marks
Before encountering this problem, try to compare several different results and summarize the difference between return and print.Summarize:One of the functions of return is returning the calculated valuePrint works by outputting data to the control
Python crawler, designed to crawl all of the individual merchant commodity information and details, and data classification analysisThe entire workflow flowchart:The first step: get all the channels from the front page in an automated way
Generate a random number in 1~10:For loop: All the objects that can be traversed can be used for a for loop, such as a string.Len (list), the type of elements in the list can be different, you can directly use subscript to assign values to the list
The Python standard library, often referred to as the "own battery", naturally offers a wide range of functions, covering about 200 packages and modules. Continuous high-quality packages or modules have been developed, greatly enriching the standard
###Python version: 2.7.13Pykafka version: 2.6.0Note: Python 3.6. Version 2 will give an error.Note: This is a production data via Pykafka module to KafkaGitHub Address: Https://github.com/Parsely/pykafkaPykafka
1. The object that directly acts on for the loop is called an iterative object:Iterable。 可以被next()函数调用并不断返回下一个值的对象称为迭代器:Iterator。2, generators are Iterator objects, but,, list dict str Although Yes Iterable , but not Iterator .Turn list , dict
1. Two ways to get the current time:
Import Datetime,time
now = Time.strftime ("%y-%m-%d%h:%m:%s")
Print now
now = Datetime.datetime.now ()
Print now
2. Get the last day of the month minus 1 days on the first day of the month
Last = Datetime.date
Python program Exercise 2-simulate a three-level menu,1. Features
This program simulates multi-level menu operations, enables you to press the corresponding Digital index of the menu item to enter the sub-menu, press B to go back to the top menu,
Knowledge about python list (recommended) and pythonlist
Let's take a look at the following!
List01 = ['Alex ', 100, 'xiaodong', 'chen', 5]List02 = [67,7, 'jinjiao _ dawang', 'relax1949', 53] # Print list01 and list02Print (list01)Print (list02) #
Compiling RESTful APIs for Django (6): ViewSets and Routers, djangorestfulPreface
In this series of articles, I wrote the Django view in the first and second articles and used the function-based method, in addition, a django-rest-framework decorator
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