首页 软件开发 代码片段 python ( Page 15 )

python 1073

#Python
bitwise operator example

>>> def b(n): print('{:08b}'.format(n)) >>> b(5) 00000101 >>> x…

2015-11-04 880

#Python
二进制复制文件

# 适合普通大小文件的复制 def text_write(infilename, outfilename): infile = open(infilename, 'r') outf…

2015-11-02 622

#Python
什么值得买签到脚本

#coding=utf-8 import requests import json s = requests.Session() headers = { 'User-Agent':…

2015-11-02 746

#Python
Python3 计算出同花的概率

每次抽取后都重新洗牌。计算10000次随机抽取可得到同花的几率。我做的比较复杂,分别累计了四种花色分别出现了几次。 import random list=["2"…

2015-11-02 1,001

#Python
一句正则表达式删除所有C语言注释

import re code_file = open('test.c','r') code_content = code_file.read() code_content_temp…

2015-11-01 614

#Python
翻页抓取

#!/usr/bin/env python #coding:utf-8 import urllib2 import re import os def getHtml(url): #…

2015-10-31 758

#Python
阶乘

def fact(x): return x > 1 and x * fact(x - 1) or 1 print fact(6)

2015-10-31 850

#Python
五子棋

from graphics import * from math import * def gobangwin(): win=GraphWin("this is a gobang …

2015-10-30 558

#Python
利用正则表达式匹配并截取指定子串并去重

import re pattern=re.compile(r'\| (\d+) \| (\d+) \|') numset=set() all=''' | 29266795 | 53…

2015-10-29 548

#Python
python 猜位置练习

from random import randint board = [] for x in range(5): board.append(["O"] * 5) def print…

2015-10-29 255
1 13 14 15 16 17 90