This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python版恶俗古风自动生成器.py | |
模仿自: http://www.jianshu.com/p/f893291674ca | |
2016年4月4日 18:37:31 codegay | |
""" | |
from random import sample | |
import time | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python解欧拉计划008-相邻13个数字最大乘积.py | |
http://pe-cn.github.io/8/ | |
2016年4月9日 07:01:13 codegay | |
我开了一个github项目来解欧拉计划,欢迎大家贡献自己的原创代码: | |
https://github.com/FGFW/projecteuler | |
""" | |
n=''.join("""73167176531330624919225119674426574742355349194934 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python判断路径是目录还是文件.py | |
http://bbs.bathome.net/thread-39957-1-1.html | |
2016年4月8日 03:04:00 codegay | |
""" | |
import os | |
files=[r for r in open("test.txt") if os.path.isfile(r.strip())] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python移动文本第A行到第N行.py | |
http://bbs.bathome.net/thread-39853-2-1.html | |
2016年4月4日 18:50:06 codegay | |
这个问题本质等于把列表元素第A个移动到第N.... | |
""" | |
with open("22.txt") as f: | |
txt=f.readlines() | |
txt.insert(4,txt[1])#第二行插入第五行的位置 | |
del(txt[1])#删除原来的第二行 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=""" | |
julia下载QQ.jl | |
从http://im.qq.com/pcqq/页面中提取出QQ的下载地址,并下载. | |
2016年4月1日 19:16:15 codegay | |
"""=# | |
url=string("http://im.qq.com/pcqq/","?",time()) | |
download(url,"qq.html") | |
f=open("qq.html") | |
txt=readall(f) | |
m=matchall(r"(?P<test>http://.*?.exe)",txt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=""" | |
julia解无忧公主的数学时间097.jl | |
http://mp.weixin.qq.com/s?__biz=MzI5ODEwMDQyNw==&mid=402225879&idx=1&sn=6ea8e1d5e6a2520ad65eb2713a98af6e&3rd=MzA3MDU4NTYzMw==&scene=6#rd | |
2016年3月29日 21:42:46 codegay | |
木有想法傻傻暴力算 | |
"""=# | |
using Iterators | |
n=[r for r in 1:7] | |
f=x->length(Set(x))==5&&x[1]<x[2]>x[3]&&x[3]<x[4]>x[end]; | |
result=[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
python解无忧公主的数学时间097.py | |
codegay 2016年3月30日 00:17:26 | |
http://mp.weixin.qq.com/s?__biz=MzI5ODEwMDQyNw==&mid=402225879&idx=1&sn=6ea8e1d5e6a2520ad65eb2713a98af6e&3rd=MzA3MDU4NTYzMw==&scene=6#rd | |
""" | |
from itertools import product | |
n=[[h for h in range(1,7+1)] for r in range(5)] | |
f=lambda x:x[1]>x[0] and x[1]>x[2] and x[3]>x[2] and x[3]>x[4] and len(set(x))==5 | |
x={r for r in product(*n) if f(r)} | |
print("097结果:",len(x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
julia文件合并排序.jl | |
http://bbs.bathome.net/thread-39841-1-1.html | |
2016年3月29日 17:29:48 codegay | |
思路如crlf所说,找出不存target中id,合并然后sort排序就可以. | |
""" | |
indexio=open("index2.txt") | |
targetio=open("target2.txt") | |
indtxt=[strip(r) for r in readlines(indexio)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
julia生成指定格式的字符串.jl | |
http://bbs.bathome.net/thread-39829-1-1.html | |
2016年3月29日 05:06:07 codegay | |
""" | |
#生成aabbcc格式的字符串 | |
ss="abcdefghijklmnopqrstuvwxyz0123456789" | |
result=open("result.txt","w+") | |
for a in ss | |
for b in ss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=""" | |
julia文本文件合并去重.jl | |
http://bbs.bathome.net/thread-39822-1-1.html | |
2016年3月27日 01:02:58 codegay | |
"""=# | |
f1=open("1.txt") | |
txt1=readlines(f1) | |
txt2=readlines(open("2.txt")) | |
txt=vcat(txt1,txt2) #以readlines取读文件流,vcat连接两个Array,julia不支持+号连接字符串和数组,支持$符内插 | |
@show length(txt) |