Learn FISHC's Python 0 basic Introductory Section 4th, this time with Python's while Loop statement and conditional statement.1. Small program for guessing numbers with a conditional statement
The program sets a number and the user enters a
>>> a= "in">>> A' \xe4\xb8\xad '>>> B=a.decode ()Traceback (most recent):File "", line 1, in Unicodedecodeerror: ' ASCII ' codec can ' t decode byte 0xe4 in position 0:ordinal not in range (128)>>> B=a.encode ("Utf-8")Traceback (most recent):File "",
The use of adorners, we can batch of old functions to transform or extend the function of old functions, such as the need to filter the function to receive parameters, Flash URL routing function is used this waydefDropoushu (): # This layer of
1: Send a request with a cookieRESP = Requests.get (Self.url_item_list_first_page, cookies=self.cookies)' http://httpbin.org/cookies '>>> cookies = dict (cookies_are='working')>>> r = Requests.get (URL, cookies=cookies)>>> r.text'{"cookies":
The list uses [] to identifyThe list and the arrays in PHP are similar including the use and access methods are similarcan be accessed directly using the subscript indexJust a few examples, it looks comfortable.names =
The mode of opening a file is:1, R, read-only mode "default".2, W, write-only mode. "Unreadable, does not exist, is created, the content is deleted"3, A, append mode. "Readable, non-existent, created, only append content exists"Second, + means you
When defining a function, we determine the name and position of the parameter, and the interface definition of the function is completed. For the caller of the function, it is sufficient to know how to pass the correct arguments and what values the
The main point here is greedy match and non-greedy match
greedy match: matches as many characters as possible; non-greedy match: matches as few characters as possiblePython's regular match is a greedy match by defaultExample:>>> Re.match (r'^ (\
About the remaining data types: stringStrings are ordered, immutable (immutable means that the variable A is re-assigned without overwriting the original value, but instead opens a new memory address in memory that stores the value of the
1.User User Table default fieldsUsername,password,email,first_name,last_name2. Adding User table Data from Import User= User.objects.create_user ('mic','[email protected] ','micpassword') user.save ()3. Create super users
Python3 manage.py
Recently in the study of Python, natural contact with the crawler, wrote a small crawler software, from the initial URL to parse the page, using the regular to get to crawl the link, using BeautifulSoup parsing to get the text, using their own
Closure function:What is a closure function:Closed refers to the definition within a functionA package refers to a function that contains a reference to the name of an outer scope (not a global scope)Def counter (): N=0 def incr (): nonlocal n x=n n+
Delete the full Python script for more than 1 years of data:VI aa.py#!/usr/bin/pythonImport OSImport datetimeImport ShutilDir= "/AA"now = Datetime.datetime.now ()Delta = Datetime.timedelta (days=365)Os.remove ("/log/110hudrm/gmss.txt")Os.mknod
The idea of binary tree realization1. Consider each node as an object that contains the following characteristics:The current value of the nodeThe left child of the node (a node object that stores a smaller value than the current node)Node right
PS: This parameter is really useless.When downloading large files, it is recommended to use Strea mode.By default, False, he will immediately begin to download files and put into memory, if the file is too large can lead to low memory situation.When
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