This file contains hidden or 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
# coding=gbk | |
import re | |
import urllib | |
#如何把name的编码转换成中文? | |
if __name__=='__main__': | |
f = open("touxiang.txt") | |
text = f.read() | |
l = text.split('},{') | |
re.findall(r'"name":"(.*)","head":"(.*)","groups":',text) | |
k = 1 |
This file contains hidden or 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
#http://stackoverflow.com/questions/5037187/formatted-input-in-python/5040181#5040181 题解 | |
f=open("x.txt") | |
d={} | |
flag=False | |
for l in f.readlines(): | |
if not flag: | |
num=(len(l)-1)/2 | |
flag=True | |
continue | |
for i in range(num): |
This file contains hidden or 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
import glob,os | |
if __name__ == '__main__': | |
p=r'E:\test1\*.jpg' | |
li = glob.glob(p) | |
k = 0 | |
for f in li: | |
i = f.rindex('\\') | |
j = f.rindex('.') | |
newf = f.replace(f[i+1:j],'%04d'%(k)) |
This file contains hidden or 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
reduce(lambda x,y:x+y,map(lambda x:str(x).count('1'), [t for t in range(13+1)])) |
This file contains hidden or 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
#输出最后一位校验码 | |
print (12-reduce(lambda x,y:x+y,map(lambda x:int(x[0])*x[1],zip('330225198708292872'[0:17],[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1])))%11)%11 |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
//strtok的实现和strtok_r一样,只是用一个static char*来维护saveptr | |
char *strtok_r(char *str,const char *delim,char **saveptr) | |
{ | |
char *ret; | |
if(str==NULL) | |
str=*saveptr; |
This file contains hidden or 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
/*2010/11/18 shihongzhi | |
* 实现了printf,itoa,ftoa | |
* todo:%f的自定义小数点没有实现 | |
*/ | |
#include <stdio.h> | |
#include <stdarg.h> | |
#include <math.h> | |
const double eps=1e-12; |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#define BITNUMBER 32 | |
#define N 10000000 | |
#define random(x) rand()%x | |
int a[N/BITNUMBER+1]; | |
void set(int i) |
This file contains hidden or 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
#include <stdio.h> | |
#define BITNUMBER 32 //int占4个字节 | |
#define N 32000 | |
int a[N/BITNUMBER+1]; | |
void set(int i) | |
{ | |
a[i/BITNUMBER]|=1<<(i%BITNUMBER); |
This file contains hidden or 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
//http://zhedahht.blog.163.com/blog/static/25411174200732711051101/ 我是倒这过来做的 | |
#include <stdio.h> | |
void print_sequence(int small,int big) | |
{ | |
int i; | |
for(i=small;i<=big;i++) | |
printf("%d ",i); | |
printf("\n"); | |
} |