受老同学所托,写了个字符串抽样的东西(就是N个字符串抽取固定的几个),代码如下:

#!python
# -*- coding: UTF-8 -*-

import os.path
import time
import sys
import itertools 
import random

if not os.path.exists("numbers.txt") :
    print u"没找到数据文件 numbers.txt"
    time.sleep(5)
    sys.exit()

with open("numbers.txt") as f :
    d = str(f.read())

#print d
numbs = d.split(",")
#print numbs, u"长度" ,len(numbs)

re = itertools.combinations(numbs, 5) #内置的一个库,so easy
re = list(re)
random.shuffle(re)                    #把顺序打乱,哈哈

with open("re.csv", "w") as f:        #按同学要求,输出为csv文件
    for p in re :
        f.write(', '.join(str(x) for x in p))
        f.write("\n")

然后?就是py2exe做成可执行文件了

from distutils.core import setup
import py2exe

setup(console=["main.py"])

非常简单的执行

python setup.py py2exe

搞定,哈哈



blog comments powered by Disqus

Published

2013-07-03

Categories


Tags

Fork me on GitHub