生成验证码的代码

C

#include <stdio.h>
int main(void)
{
	FILE *fptr = fopen("code.txt", "w");
        for(int i=0; i<=999999; i++) {
                fprintf(fptr, "%06d\n", i); 
        }
	fclose(fptr);
        return 0;
}

Python

f = open("code.txt", "wt")
for i in range(1000000):
	f.write("{0:06}\n".format(i))
f.close()

用python写程序果然比C语言写得更快一些, pyhon代码都更短一些,只是追求执行效率的还是要用C语言来写.

posted @ 2021-08-26 13:55  enjoy_jun  阅读(188)  评论(0编辑  收藏  举报