In Python programming, you often need to output the results in print, and if you want the output to be displayed on the IDE's screen or in a file (such as TXT), what should I do?Method 1You can output information to a file or screen via the Log
Reprint: http://www.jb51.net/article/59296.htmRecently encountered a problem is to specify parameters to run a particular process, which is very similar to some of the parameters of Linux commands, such as ls-a, why the plus-a option will respond.
# no parameters and returned functions def say_hi (): print ("hi!") Say_hi () Say_hi () # has parameters, no return value Def print_sum_two (A, B): C = a + b print (c) Print_sum_two (3, 6) def hello_some (str): print ("Hello" + str + "!")
Hello World Programprint("Hello World!")Then execute the output:Hello World!Execute under InteractivePython 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit (AMD64)] on win32Type "copyright", "credits" or "license()" for more
Because the HTTP protocol is a stateless protocol (if the login is successful when accessing other Web pages of the site, the login state disappears), the session information needs to be saved, through a cookie or sessionCookiesSave all the reply
Achieve goals
1. The ancient Poetry website crawls the Tang and song Ci2. Landing to local database
Page analysis
Page positioning via Firedebug:SOURCE Location:Locate div tags according to lxml etree:# page Analysis
develop a sensitive word filter that prompts the user to enter comments if the user enters content that contains special characters:#list of sensitive words li = ["Cang teacher", "Tokyo Fever", "Enrique", "Yui Hatano")#The sensitive words in the
The code is as follows:1 Importdatetime2 Import Time3 4Datetime_format ="%y-%m-%d%h:%m:%s"5Date_format ="%y-%m-%d"6 7 defget_now_timestamp_13 ():8 returnInt (time.time () *1000)9 Ten defget_now_date (): One returntime.strftime (date_format)
Python BasicsOne, Windows installation Python3.5: Https://www.python.org/ftp/python/3.5.2/python-3.5.2rc1-amd64.exeDouble-click Install in directory c:/python35Setting environment variablesAdd a newly installed Python directory later to open the
Adorner:Definition: Essentially a function (used to decorate other functions, i.e. add additional functionality to other functions)Principle: 1. Cannot modify the source code of the decorated function2. Cannot modify the calling mode of the
First, what is the __init__ method?Students who have written object-oriented code in Python may be familiar with the __init__ method, and the __init__ method is often used to initialize a class instance. For example:#-*-Coding:utf-8-*-class Person
The regular expression, which is simpler, is a matching function, in Python, as long as the re module is referenced, you can do regular matching operationsOne, Math matchLet's look at a simple exampleImport Rere.match (pattern, data_source)
CSS selectors commonly used selectors are as follows: 1, Tag Selector tag Selector, this kind of selector has a large scope of influence, it is recommended to apply in the hierarchy selector as far as possible. Example:
if __name__ = = ' __main__ ':When you open a. py file, you will often see if __name__ = = ' __main__ ' at the bottom of the code: Now let's introduce its role.The module is an object, and all modules have a built-in property of __name__. The value
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