1. Describe two lines in the following code #The first line of comments is to tell the Linux/os x system that this is a python executable and the Windows system ignores this comment;The second line of comments is to tell the Python interpreter to read the source code according to the UTF-8 encoding, otherwise the Chinese output you write in the source code may be garbled.#!/usr/bin/env
recently read Jane book articles focused on a number of topic authors, written articles are good, the crawler and data analysis are written very well, so thought can get the latest article pushed to the ipad NetEase mailbox master. the message sending code is encapsulated into a function, learned from the great God of the XuefengHttp://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/ 001386832745198026a685614e7462fb57dbf733
Python phone book management example
#! /Usr/bin/env python # coding = UTF-8 # manage the phone book. you can add, delete, modify, and query user information. import cPickle as p class Telephone: def _ init _ (self): ''' constructor ''' def addPeople (self, name, email, tele
the ASCII code storage space, So there's a UTF-8 encoding that converts Unicode encoding into variable-length encoding; in computer memory, Unicode encoding is used uniformly, and is converted to UTF-8 encoding when it needs to be saved to the hard disk or when it needs to be transferred.Python's string type is str, in memory in Unicode, a character corresponding to a number of bytes, if you want to transfer on the network or save to disk, you need to turn str into bytes.In
Learn python for a few months just practice practiced hand, found that problems continue to improve, first from the topic, crawl some data, a start on the book site structure is not familiar with, crawl recommended, popular, City 3 navigation bar, Exchange found recommendations and hot is the sort of different, the URL will be repeated, as well as each feature details page Three categories of latest comment
)--->true string A word typeface multiply, out of the 20 range is the same two memory addresses: S1='h'* +S2='h'* +Print (S1 isS2)--->falseOther data typesThe list dic tuple set has no small data pool conceptTake list For example: L1=[1,]l2=[1,]print (L1 is L2)--- >falseCodingAsciiNo Chinese only English one byte (bytes) ==8 digit (bit)UnicodeEnglish: 32 bits 4 bytesEnglish: 32 bits 4 bytesUtf-8English: 8 bits 1 bytesEnglish: 24 bits 3 bytesGBKEnglish: 8 bits 1 bytesEnglish: 16 bits 2 bytes1.
First, understand the difference between encode () and Decode ()
The role of Encode () is to convert a Unicode-encoded string to another encoding format.
For example: St1.encode ("Utf-8") is the function of encoding a UNICODE encoded ST1 as a UTF-8 encoded string
The role of Decode () is to convert strings of other encoded formats into Unicode-encoded strings.
For example: St2.decode ("Utf-8") is a sentence that decodes a utf-8 encoded string st2 into a Unicode-encoded string
Second, in add
Write an address book code in python
Reference knowledge
List + dict: used to temporarily store user data
CPickle is used to access formatted files.
Still use file for file storage
Solve the Problem 1. Start to do it
Original code implementation function (can be used as a template)
1. Check whether the input content is in the given menu directory. If yes, the corresponding result is returned. If
Today, I'm here to share 10 good Python books that you can not miss, for beginners, advanced to three different stages of reading.Python High Performance programmingAmazon five-star bestseller.Python entry advanced must-read.Python code only works correctly enough, you need to make it run faster.Python Core Programming (3rd edition)The series sold more than 70,000 copies.Advanced Python Master
Second day, busy home some things, shun with people to crawl the watercress book top2501. Construct the URLs list urls=[' https://book.douban.com/top250?start={} '. Format (str (i) for I in range (0, 226, 25))]2. Module requests get webpage source code lxml Parse Web page XPath extract3. Extracting information4, can be encapsulated into a function here does not encapsulate the callPython code:#coding: Utf-8
[python] book information crawler sample
Background Notes
Need to collect some book information, in watercress book entries as the source, get some valid book information, and save to the local database. get a book category labe
series solved with this method)Log in with super privileges, set environment variablesCommand: sudo gedit/etc/profileEnter at the bottom of the document: (Hint: The path entered after Pythonpath= is the Caffe path installed under Linux)Pythonpath=caffe/python: $PYTHONPATHExport PYTHONPATHCommand: Source/etc/profilePythonImport Caffe6.test:Command: Python draw_net.py e.g. ./
Python is a fire, and that's no doubt, so how do I get started? A lot of small white are very confused, do not know how to start, although the small series want to give everyone to send paper books, after all, the paper book looks like some, but the small part is still relatively poor, can not afford to send, to everyone dozens of PDF book it! Private messages Sm
This article introduces the content is Selenium+python how to crawl simple book site, has a certain reference value, now share to everyone, the need for friends can refer to
Page load Logic
When you learn the basic knowledge of the crawler from the Internet, like to find a goal in practice, has a large number of articles containing a large number of concise book
" " Date: September 5-September 30 Requirements: 1. Summary of the book contents, finishing in the blog Park notes upload 2. After all the exercises in the course Note: "#" After the addition of the notes (42 pages per day, you can guarantee to read this book at the end of the month) "Key Notes" "chapter Exercises"-Heading 1, level two headings- Heading 2, Notes outline title, exercise title-Bold, 16px"Summ
Tags: operations database python Java managementThe history of human reading is almost the history of human civilization. Book is the carrier of human spiritual wealth, human progress and achievements are recorded in the book, Inherit and flourish. "World Study Day" is only one day, but its meaning is to make every day a "reading Day". Let reading become our life
field of vision.
Learn the Django method is under Ubuntu, according to the Django Book project, a project is over, it is almost, and then write their own ideas, encountered problems themselves Baidu Google what.
Wrote a comparison to take a shot is to use Python to calculate the PV power system design parameters, and then generate a CSV data file, to tutor demonstration, she let me expand again, I am rea
#!/usr/bin/env python#coding=utf-8# Phone Book management, you can add, delete, modify, query user information import Cpickle as P class Telephone:def __init__ (self): "Construction Method" Def addpeople (Self,name,email,telephone): "" "Add User" "" Teledict = Self.getdictda Ta () if teledict:infolist = [Name,email,telephone] teledict[name] = info
, phone: 1234567. enter the command: sq $ Python3 addressbook. for py, enter the command: search, enter the name of the contact to be searched: zhangsan name: zhangsan, link: friend, phone: 1234567, enter the command: addperson, enter the name: lisi please select group (0: family, 1: friends, 2: colleagues): 1 please enter Phone: 1234567 please enter Command: q not found command! Enter command: quit $ Python3 addressbook. py enter Command: search enter the name of the contact to be searched: lis
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.