:/python Training/s14/day5/shelve module/shelve_test.py2 dean3 it4 2016-08-24 16:04:13.3254825 6 Process Finished with exit code 010. Regular RE Module1 '. ' The default match is any character except \ n, if you specify flag Dotall, match any character, including the line 2 ' ^ ' match character beginning, if you specify flags MULTILINE, this can also match (r "^a", "\nabc\neee", flags =re. MULTILINE) 3 ' $ ' matches the end of the character, or E.search ("foo$", "BFOO\NSDFSF", Flags
a common regular expression:1, "." : Default match any character except \ n, if flag Dotall is specified, matches any character, including line break2, "^": match the beginning of the character, if you specify flag MULTILINE, this can also match on (R "^a", "\nabc\neee", Flags=re. MULTILINE)3, "$": matches the end of the character, or Re.search ("foo$", "BFOO\NSDFSF", Flags=re. MULTILINE). Group () can also4, "*": match the character before the * number 0 or more times, Re.findall ("ab*", "Cabb
algorithm to do encryption. Print ("". Center ("*")) M1=hashlib.md5 (bytes ("Encrypt on Build", encoding= "UTF8")) m1.update (bytes ("I", encoding= "UTF8")) M1.update (b ' It is Me ') print ("Binary", M.digest ()) print ("Hex", M.hexdigest ())RE module: The regular expression is the string matching rules, in most programming languages have corresponding support, Python corresponding module is re'.'default match any character except \ n, if flag Dotall is specified, matches any character, includ
‘.‘ Default match any character except \ n, if flag Dotall is specified, matches any character, including line breakThe ' ^ ' matches the beginning of the character, and if you specify the flags MULTILINE, this can also be matched on (r "^a", "\nabc\neee", and flags = Re. MULTILINE)' $ ' matches the end of the character, or E.search ("foo$", "BFOO\NSDFSF", flags = Re. MULTILINE). Group () can also' * ' matches the character before the * number 0 or more times, Re.findall ("ab*", "Cabb3abcbbac")
matching: BF, BM, KMP
BF (Brute Force) algorithm
The basic idea of Brute-force algorithm:
Compares the first character of the target string s with the Fu Qi of the pattern string T, and if it is equal, continues to compare the subsequent characters individually, otherwise the second word from the string s is Fu Qi and the string T is compared again.
And so on, until each character in the string T is equal to a contiguous sequence of characters in the string s, the pattern match succeeds, an
word from the string s is Fu Qi and the string T is compared again.
And so on, until each character in the string T is equal to a contiguous sequence of characters in the string s, the pattern match succeeds, and the position of the first character of the string T in the string s is the position of T in S, otherwise the pattern match is unsuccessful
It can be seen that the BF algorithm is a brute force algorithm, also known as a simple matching algorithm or brute forces algorithm.
Main str
teacher!I teach linux.I like badminton ball,billard ball and chinese chess.my blog is http://oldboy.blog.51cto.comour site is http://www.etiantian.orgmy qq num is 49000488.not 4900000448.my god,i am not oldbey,but OLDBOYoldb y[[emailprotected] ~]# grep "[^0-9]" linbin.txt ##匹配非数字I am oldboy teacher!I teach linux.I like badminton ball,billard ball and chinese chess.my blog is http://oldboy.blog.51cto.comour site is http://www.etiantian.orgmy qq num is 49000488.not 4900000448.my god,i am not old
discuss several classic algorithms for string matching: BF, BM, and KMP.
BF (Brute Force) algorithm
The basic idea of the Brute-Force algorithm:
Compare the first character of the target string s with the first character of the mode string t. if they are equal, continue to compare subsequent characters one by one, otherwise, repeat the string t from the second character of string s.
So far, when each character in string t is the same as a continuous character sequence in string s, the pattern m
Inheritance: Inheritance is the technique of building a new class using the definition of an existing class, and the new class inherits the old class, which can be used to get some of the data from the old class. Examples include inheritance of instance variables and inheritance of methods.Old Class AAA@interfance Aaa:nsobject{int Val;}-(int) Intvar;@end@implementation Aaa-(int) Intvar{var=1000;return var;}@endNew class ABB#import "Aaa.h"@interface AB
Title: https://www.lydsy.com/JudgeOnline/problem.php?id=1026Quite simple digital DP, pre-F[I][J] represents the number of I digits, the number of windy starting with J;But do not understand why the last one to take out a special sentence ret++ wrong, and write in the loop, special i==1 on the right ...The code is as follows:#include #include#include#includeusing namespacestd;inta,b,f[ the][ the],num[ the];intAbbintx) {return(x>0)? x:-x;}intGetnum (intx) { intCnt=0; while(x) num[++cnt]=x%Ten,
ModulesTwo modules for serializationJSON, used to convert between string and Python data typesPickle for conversion between Python-specific types and Python data typesThe JSON module provides four functions: dumps, dump, loads, loadThe Pickle module provides four functions: dumps, dump, loads, loadHashlib ModuleFor cryptographic related operations, the 3.x replaces the MD5 module and the SHA module, mainly providing SHA1, SHA224, SHA256, SHA384, SHA512, MD5 algorithmImport HMACh = hmac.new (' W
). [] [^]#!/usr/binl/env Python#encoding:utf-8#author:yangleiimport re#, which itself represents any one character print (Re.findall (' a.c ', ' a A1C a*c a2c ABC a C AAAAAAC AACC ')) #[] can have multiple characters inside, but only one print of multiple characters (Re.findall (' a[0-9][0-9]c ', ' a a12c A1c a*c a2c a C a\nc ', re. S)) Print (Re.findall (' a[a-za-z]c ', ' AAC ABC AAC a12c A1C a*c a2c a C a\nc ', re. S)) Print (Re.findall (' a[^a-za-z]c ', ' AAC ABC AAC a12c A1C a*c a2c a C a\nc
, including the line 2 ' ^ ' match character beginning, if you specify flags MULTILINE, this can also match (r "^a", "\nabc\neee", flags =re. MULTILINE) 3 ' $ ' matches the end of the character, or E.search ("foo$", "BFOO\NSDFSF", Flags=re. MULTILINE). Group () can also 4 ' * ' matches the character before the * number 0 or more times, Re.findall ("ab*", "Cabb3abcbbac") results for [' ABB ', ' ab ', ' a '] 5 ' + ' Match previous chara
Import Hmach = Hmac.new (b ' 12345 ', ' King of the Land Tiger '. Encode (encoding= ' utf-8 ')) Print (H.digest ()) print (H.hexdigest ()) Re module '. ' default match any character except \ n, if flag Dotall is specified, matches any character, including the newline ' ^ ' match character beginning, if Flags is specified MULTILINE, this can also be matched on (r "^a", "\nabc\neee", Flags=re. MULTILINE) ' $ ' matches the end of the character, or E.search ("foo$", "BFOO\NSDFSF", Flags=re. MULTILI
* * Reprinted from: http://www.cnblogs.com/alex3714/articles/5161349.html**
Re module common methods
Re.match (rule, String): Default starting from the beginning of the match, this mode is ‘^‘ useless.
Re.search ()
Re.findall (): There is no group way, put all matching characters to the list of elements returned
Re.split (): Split
Re.sub (): Match character and replace
Common Regular Expressions:'. 'Default match except\Any character other than n, if flag Dotal
#重复匹配:. [] ? * + {}?: The left character appears 0 or 1 timesPrint (Re.findall (' ab ', ' a ab ABB abbb abbbbbb '))Print (Re.findall (' ab{0,1} ', ' A ab ABB abbb abbbbbb '))*: The character on the left appears 0 or infinite timesPrint (Re.findall (' ab* ', ' a ab ABB abbb abbbbbb abbc123bbbb '))Print (Re.findall (' ab{0,} ', ' A ab
Expression symbols‘.‘ The default match is any character except \ n, if you specify flag Dotall, match any character, including the newline ' ^ ' match character beginning, and if you specify flags MULTILINE, this can also match (r "^a", "\nabc\neee", Flags=re. MULTILINE) ' $ ' matches the end of the character, or E.search ("foo$", "BFOO\NSDFSF", Flags=re. MULTILINE). Group () can also ' * ' match the character before the * number 0 or more times, Re.findall ("ab*", "CABB3ABCBBAC") result for [
The function of regular expressions: matching stringsCommon Regular Expression symbols‘.‘ The default match is any character except \ n, if you specify flag Dotall, match any character, including the newline ' ^ ' match character beginning, and if you specify flags MULTILINE, this can also match (r "^a", "\nabc\neee", Flags=re. MULTILINE) ' $ ' matches the end of the character, or E.search ("foo$", "BFOO\NSDFSF", Flags=re. MULTILINE). Group () can also ' * ' match the character before the * numb
with the same as above, but at least one B exists ("AB", "abbb", etc.);
"AB": Synonymous with ab{0,1}, can be without or only a B;
"a?b+$": a string that matches the end of one or 0 a plus more than one B.
Points, ' * ', ' + ', and '? ' Just the character in front of it.
You can also limit the number of characters appearing in curly braces, such as
"Ab{2}": Require a must be followed by two B (one also can not be less) ("ABB");
"Ab{2,}": Require a mu
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.