前言:python统计apache.nginx访问日志IP访问次数并且排序(显示前20条).其实用awk+sort等命令可以实现,用awk数组也可以实现,这里只是用python尝试下. apache脚本: ips = {} with open("/root/mail_access_log-20180629") as fh: for line in fh: ip = line.split(" ")[0] if 6 < len(ip) <=15: ips…
后一个分数的分子=前一个分数的分子+分母,后一个分数的分母=前一个分数的分子,循环个20次就有结果.注意,假设分子为a,分母为b,虽然 a = a + b, 但此时a已经变成 a+b 了,所以再给b重新赋值的时候,得是 (a+b)-b 才能等于原分母b,所以重新赋值时就得写成 a-b 方法一 from fractions import Fraction def fibonacci(n): a, b = 1, 2 res = [1] i = 1 while i < n: a, b = b, a+b…
按照数据行数查询 name, row_count(db_id(), id) from sysobjects order by row_count(db_id(),id) desc 按照分配的空间查询 name, reserved_pages(db_id(),id)/(1024.0 / (@@maxpagesize/1024.0) ) as "Allocated MB" from sysobjects order by reserved_pages(db_id(),id) desc 按照…
46 Simple Python Exercises This is version 0.45 of a collection of simple Python exercises constructed (but in many cases only found and collected) by Torbj�rn Lager (torbjorn.lager@ling.gu.se). Most of them involve characters, words and phrases, rat…
1.总结Oracle .sqlserver和mysql中查询10-20条记录的写法 一: oracle数据库写法: 1:select * from (select rownum rn ,* from 表名 wher rownum<20) a where a.rn>10 2:select * from 表名 where rownum<20 minus select * from 表名 where rownum<10 二:SqlServer数据库写法: 1:select top 20…