Python adorner, string, Cookielib module
Python decode and encode solve string encoding problems
Principle: Python is Unicode-encoded internally. (Unicode encoding is a broker)
Decode converting other encodings to Unicode encoding
Encode converting Unicode encoding to other encodings
Python Action Cookie:
Knowledge Point: set-cookie:session=8345234;expires=sun,15-nov-2013 15:00:00 gmt;path=/;d omain=baidu.com
Expires is the life cycle of a cookie, path is the valid path to the cookie, and domain is the valid field of the cookie.
The path "path" is used to set the topmost directory where a cookie can be read.
Setting the path of the cookie to the top-most directory of your page allows all pages in that directory to have access to the cookie.
Method: Add path=/to your cookie; If you only want the pages in the "Food" directory to be able to use the cookie, you join Path=/food.
Domain: Some sites have many small domain names, such as Baidu may also be in the "news.baidu.com" "zhidao.baidu.com" and "v.baidu.com" domain name has a page.
If you want to allow all machines under "baidu.com" to read the cookie, you must include "domain=.baidu.com" in the cookie.
The user's browser stores the cookie until it expires, and the browser sends an HTTP request header similar to the following to the server that conforms to path and domain:
cookie:session=8345234.
For example, when landing www.baidu.com, the Baidu server sends back the HTTP response header in the cookie:
set-cookie:h_ps_pssid=4681_4567_1452_9876_4759; path=/; Domain=.baidu.com
set-cookie:bdsvrtm=74; path=/
HTTP request header for browser:
cookie:baiduid=0fd996sdfg12********107b9c227f4c:fg=1; Locale=zh; bdshare_firstime=1384567418140; nbid=d830dd2345hh2818a9f4134e5a2d778d3b:fg=1; h_ps_lc=4_shadu2014; Bd_ck_sam=1; h_ps_pssid=4681_4567_1452_9876_4759
Python common function Time.strftime ()
Time.strftime () can be used to get the current time, you can format the time as a string, etc.
%a shorthand for the day of the week
%A full name of the week
%b of the Month
Full name of the%B month
Time string for the date of%c standard
After two digits of the%c year
The day ordinal of a month in%d decimal notation
%d Month/day/year
%e the day ordinal of a month in a two-character field, in decimal notation
%F year-month-day
%g two digits of the year, using week-based
%G years, using week-based years
%h Abbreviated month name
%H 24-Hour Hour
%I 12-Hour Hour
%j decimal indicates the day ordinal of the year
%m the month represented by decimal
%M minutes in a 10 o'clock-hour representation
%n New Line character
%p equivalent display of the local AM or PM
%r 12 hours of time
%R display hours and minutes: hh:mm
%s number of seconds in decimal
%t Horizontal Tab
%T display time seconds: hh:mm:ss
%u days of the week, Monday for the first day (values from 0 to 6, Monday to 0)
%u year of the week, the Sunday as the first day (value from 0 to 53)
%V Week of the year, using week-based
%w Decimal Day of the week (value from 0 to 6, Sunday is 0)
%W Week of the year, Monday as the first day (value from 0 to 53)
Date string for%x standard
Time string for%x standard
%y decimal Year without century (values from 0 to 99)
%Y 10 year with century part
%z,%z the time zone name and returns a null character if the time zone name cannot be obtained.
Percent hundred percent semicolon
Python adorner, string, Cookielib module