Statistics Nginx access log, Access.log form:1xx.xx.xxx.xxx--[09/oct/2017:10:48:21 +0800] "get/images/yyy/2044/974435412336/cover/9787503434r.jpg HTTP/1.1" 304 0 "http://www.xxx.net/" "mozilla/5.0 (Windows NT 6.1; Win64; x64) applewebkit/537.36 (khtml, like Gecko) chrome/xx.0.xx2.xx safari/537.36 "0.001" "-" "-" "-" xxx.xxx.xxx.xxx:xxxx "" 304 "" 0 "" 0.001 "(1) The domain name and number of visits will be stored in the database(2) List the top 10 dow
MATH.SQRT (4), the square root is computed, and the result is 2.0SQRT (-4) error, cannot process imaginary numbers (end with j), requires import Cmath, uses Cmath.sqrt (-4)
The program automatically ends, you can add Raw_input ("Press") at the end of the code
Concatenation of strings, "hello." + "World"string printing, str ("Hello,world") #转换为用户看到的字符串 Hello,worldRepr ("Hello,world") #以合法的python表达式形式表示 ' Hello,world 'This conversion is useful
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
This article mainly introduces how to use python to collect statistics on the ratio of men and women in school BBS. For more information, see
I. project requirements
Each user id on the BBS corresponds to a user. During registration, the user will enter the gender (male, female, and confidentiality ).
After checking, the id of the BBS registered user corresponds to 1-300000, which is about 0.3 million of t
The Pandas object has some common mathematical and statistical methods. For example, the sum () method, which makes the column subtotal: the sum () method passed in Axis=1 is specified as a horizontal summary, which is subtotal: Idxmax () gets the index of the maximum value: There is also a rollup that is cumulative, cumsum (), compared to it and Su The difference between M ():The unique () method is used to return only values in the data: the Value_counts () method is used to count how often e
Python exercise question 012: character statistics, python012
[Python exercise 012]Enter a line of characters to calculate the number of English letters, spaces, numbers, and other characters.
-----------------------------------------------
This is not difficult. The logic is clear. As long as you know the corresponding value of the ASCII code table, you know tha
Homepage of Editorial Office: It doesn't seem to work.Http://shop.oreilly.com/product/0636920022923.doEach chapter of the code, GitHub above: Chinese versionHttps://github.com/willard-yuan/pcv-book-codeOn GitHub above, English version:Https://github.com/jesolem/PCVProject homepage:Http://programmingcomputervision.comChinese online book:Http://www.ituring.com.cn/tupubarticle/2024?utm_source=tuicoolthen download the installationpython (x, y):https://cod
Create an Address book query software that temporarily supports search by name only. Starting point: You can retrieve it without logging into the Enterprise Portal. Be careful to protect the employee's phone number unless he or she agrees to display it.You are welcome to visit WWW.CNBLOGS.COM/VIPHHS. Reprint please contact the author authorization.Ideas:1, crawling crawl basic data, in a dictionary and a list of the way to store.2. Store this data in
#!/usr/bin/pythonImport SysImport OSIf Len (sys.argv) = = 1:data = Sys.stdin.read ()ElseTryfn = sys.argv[1]Except Indexerror:Print "Follow a argument at%s"%__file__Sys.exit ()If not os.path.exists (FN):Print "%s is not exits."%fnSys.exit ()FD = open (Sys.argv[1])data = Fd.read ()chars = Len (data)Words = Len (Data.split ())lines = Data.count (' \ n ')Print "% (lines) s% (words) s% (chars) S"%locals ()This article from "The Miracle of the Youth" blog, reproduced please contact the author!
#-*-coding:utf-8-*-#===============================================================================# in Folder# 1, total number of statistical documents# 2. Count the number of files in various formats# 3, log output#===============================================================================Import Os,time,sysDef getprettytime ():Return Time.strftime ('%y-%m-%d%h:%m:%s ', Time.localtime ())def log (content):f = open (' Log.txt ', ' aw+ ')F.write (' F.write (content + ' \ n ')F.close ()def run
for a list, for example [1,2,2,2,2,3,3,3,4,4,4,4], now I want to count the duplicates in this table and repeat them several times. EG1:mylist = [1,2,2,2,2,3,3,3,4,4,4,4]MySet = set (MyList) #myset是另外一个列表 with no duplicates inside MyListFor item in MySet:print ("The%d has found%d"% (Item,mylist.count (item)))EG2:list=[1,2,2,2,2,3,3,3,4,4,4,4]a = {}For i in List:if List.count (i) >1:A[i] = List.count (i)print (a)use the characteristics of the dictionary to achieve. eg3:>>> from collections import
#!/usr/bin/env pythonimport random# ' abc. Z ' alphastr = "". Join (Map (CHR, Range (97,123))) FP = open ("Word.txt", "w") Maxiter = 100000for i in range (maxiter): word = "" Len =random.randint (1,5) for J in Range (len): word + = Alphastr[random.randint (0,25)] fp.write ( Word + ' \ n ') Fp.close () Cat Word.txt |./wordcount_mapper.py |./wordcount_reducer.py. Word count reduce, python#filename: wordcount_reducer.pyfrom op
For a list, such as [1,2,2,2,2,3,3,3,4,4,4,4], now we need to count the duplicates in this table and repeat them several times to count them out.Method 1:?
1234
mylist = [1,2,2,2,2,3,3,3,4,4,4,4]myset = set(mylist) #myset是另外一个列表,里面的内容是mylist里面的无重复 项for item in myset:print("the %d has found %d" %(item,mylist.count(item)))
Method 2:?
123456
List=[1,2,2,2,2,3,3,3,4,4,4,4]a = {}for i in List:if List.count(i)>1:a[i] = List.count(i)print (a)
Use the ch
)String tuples: Tuple (String)In []: sOUT[24]: [' A ', ' a ', ' a ']in [+]: tuple (s)OUT[26]: (' A ', ' a ', ' a ')Tuple to string: '. Join (tuple)In [SI]: type (a)OUT[54]: Tuplein [+]: a = str (a)in [+]: AOUT[56]: "(' A ', ' B ', ' C ', 111)"In [the]: type (a)OUT[57]: StrDictionary goto list:in [+]: dic = {' A ': 1, ' B ': 2}in [+]: dicOUT[29]: {' A ': 1, ' B ': 2}in [+]: Dic.items ()OUT[30]: [(' A ', 1), (' B ', 2)]List to Dictionary:In [to]: L1 = Dic.items ()in [+]: L1OUT[32]: [(' A ', 1), ('
the last word on increasing tariffs, Whether it but Trump have no patience to follow such procedures. Instead He is issuing executive orders to satisfy his political base. ' \' The Republicans in Congress were shocked this their leader would take such a protectionist action, recognizing it was mor E about politics than national security. Their swift opposition forced Trump to make Canada and Mexico exceptions (to is part of the North American free trade agreemen T negotiations), and eventually
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.