前几天朋友圈看到几条转发大意是“12月3日星期四是百年一遇的步步高升日”之类,出于专业的qa态度(其实就是无聊)就写了段代码算一下。。。
#计算从1970年起1000年内有哪些年的12月3日是星期四
c=[] for i in xrange(1970,2970): a=(str(i)+'/12/03 00:00:00') atimestamp=int(time.mktime(time.strptime(a,'%Y/%m/%d %H:%M:%S'))) if time.strftime('%A',time.localtime(atimestamp))=='Thursday': c.append(i) print c
结果这货也就10年左右一遇啊。
[1970, 1981, 1987, 1992, 1998, 2009, 2015, 2020, 2026, 2037, 2043, 2048, 2054, 2
065, 2071, 2076, 2082, 2093, 2099, 2105, 2111, 2116, 2122, 2133, 2139, 2144, 215
0, 2161, 2167, 2172, 2178, 2189, 2195, 2201, 2207, 2212, 2218, 2229, 2235, 2240,
2246, 2257, 2263, 2268, 2274, 2285, 2291, 2296, 2303, 2308, 2314, 2325, 2331, 2
336, 2342, 2353, 2359, 2364, 2370, 2381, 2387, 2392, 2398, 2409, 2415, 2420, 242
6, 2437, 2443, 2448, 2454, 2465, 2471, 2476, 2482, 2493, 2499, 2505, 2511, 2516,
2522, 2533, 2539, 2544, 2550, 2561, 2567, 2572, 2578, 2589, 2595, 2601, 2607, 2
612, 2618, 2629, 2635, 2640, 2646, 2657, 2663, 2668, 2674, 2685, 2691, 2696, 270
3, 2708, 2714, 2725, 2731, 2736, 2742, 2753, 2759, 2764, 2770, 2781, 2787, 2792,
2798, 2809, 2815, 2820, 2826, 2837, 2843, 2848, 2854, 2865, 2871, 2876, 2882, 2
893, 2899, 2905, 2911, 2916, 2922, 2933, 2939, 2944, 2950, 2961, 2967]