Seventh chapter, Python character encodingfirst, the definitionThe information stored in the computer is represented by a binary number, and the characters we see on the screen, such as English, Kanji, and so on, are the result of binary conversion.
Citation:http://www.cnblogs.com/haiyan123/p/7298967.htmlUnderstanding ModulesCommon Module CategoriesRegular expressionsRe moduleThe relationship between the RE module and the regular expressionCollections Modulefirst, the understanding moduleWhat
#turn datetime into a stringdefdatetime_tostring (DT):returnDt.strftime ("%y-%m-%d-%h")#turn a string into a datetimedefstring_todatetime (String):returnDatetime.strptime (String,"%y-%m-%d-%h")#turn the string into a timestamp
1. Initial knowledge of file operation
Normal operation (too low: no indentation, need to close, code is not aesthetically pleasing)f = open ('path', mode='r', encoding='utf-8 ')F.read ()F.close ()
Advanced operation (High Force lattice:
Add by ZHJ: For a multi-line string connection, the 6th connection method is convenient and no additional space is added when connecting.Original: http://www.cnblogs.com/bigtreei/p/7892113.html1. PlusFirst, people with programming experience know
Remember that the number of elements in the data structure is nListing (list)The list is implemented by the array, and the allocated memory is a contiguous space. Adjust and modify the list elements to return the length of the list, the time
Tag: image represents an optional parameter PNG string class NTP src output error1.argparse module functionUsed to parse command-line arguments2. Position parameters and optional parametersRun the following code:import argparseparser =
python provides an inline module, Buildin. The inline module defines a number of functions that are often used in development, using these functions to transform data types, calculate data, and process sequences. The common functions in the inline
Python implementation of Leetcode Primary algorithm--string# invert string def reversestring (s): Return s[::-1]# reverse number def reverse (x): if x Flag:return 0 Else: Return result# the first unique character in a string def firstuniqchar (s):
1. Coding issues
The initial encoding is ASCII, and a byte can represent all English, special characters, numbers, and so on.
Unicode One Chinese character is represented by four bytes.
In the upgraded version of Utf-8, a Chinese
Basic data types1. Digitalint (integral type)On a 32-bit machine, the number of integers is 32 bits and the value range is 2**31-2**31-1, which is -2147483648~2147483647On a 64-bit system, the number of integers is 64 bits and the value range is -2**
Index, subscript, to get a character in a character" Alex " = test[0:1] # Displays the No. 0 print(v)A line of characters vertical lines loops apart" fruit What's happening in Guangdong Province company " = 0 while index len (test): =
#-*-coding:utf-8-*- ImportSmtplib fromEmail.mime.textImportMimetext fromEmail.headerImportHeader#third-party SMTP servicesmail_host="smtp.qq.com" #setting up the serverMail_user="QQ number @qq.com" #User namemail_pass="password for the
Installation: BEAUTIFULSOUP4 fromBs4ImportBeautifulSoupYoyo= Open(' yoyo.html ',' R ') # open "yoyo.html" file in read mode# Print (Yoyo.read ()) # This method opens a string that contains no hierarchy# Yoyo.close ()Soup= BeautifulSoup(Yoyo'
With open ('information.txt','r+', encoding=' Utf-8') as F:Be sure to specify the encoding method, it is not the same as the simple open function, not the default is Utf-8 encoding.Print (" %s %s%s%s" % (k, Get_price (k), Val, Val * Get_price
Black Magic Collection for the creation of classes omit selfFrom types import functiontypefrom byteplay import Code, Opmapdef metaclassfactory (function): Class Metaclass (Type): def __new__ (Meta, classname, bases, classdict): For
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