`
ipython
  • 浏览: 295330 次
  • 性别: Icon_minigender_1
  • 来自: 佛山
社区版块
存档分类
最新评论
文章列表
将.py生成.pyc文件 # filename 为.py的文件路径 import py_compile py_compile.compile(filename)     可变长参数(函数中的参数个数不确定) def multipar(*s):   ss = ''   for i in s:      ss += i   return ss   a = multipar('aa') b = multipar('aa','bb') c = multipar('aa','bb','cc') print a,b,c
之前写过C语言快速排序的算法,今天在《数据结构》(C语言版)清华大学出版社的快排,感觉比之前的更快,于是贴出来。 在我的机子上,排序100w的数据,只要0.3秒!其中我用python写了一个小脚本来生成100w个的随机数。附件为测试数据,本程序在GCC下编译通过。 #include "stdio.h" #include "time.h" int shu[1000000]; int i,j,k,len; void quick_sort(int left,int right); void read_file(); void wr ...
以下是十分简单的python写的爬虫小脚本。 import os,re import urlparse,urllib,urllib2 import hashlib,Queue class Request(object): def __init__(self): self.url= '' self.error_url = [] self.undownload_url = [] self.downloaded_url = [] self.headers={'User-Agent':' ...
以下是作业,用它用实现用邻接矩阵的方式来进行广度优先和深度优先的遍历。 代码比较简单,用了两个小时来写出来。   /**用邻接矩阵的方式来储存图,用广度优先方式进行遍历 **/ #include "stdio.h" #define max_matrix 10 int visited[max_matrix],matrix[max_matrix][max_matrix]; int n; int board_traverse(); int main() { int i,j; scanf("%d",&n); ...
在Windows XP下硬盘安装fedora 13   1.分区,用Partition Manager 生成一个fat32格式的分区(如I盘),用来存放iso文件,生成磁盘后,将这个盘命名为fedora( 下面有用)(磁盘,右键,属性,常规) 2. 下载 fedora 的ISO文件 这里 ,放到 I盘, ...
disp("Hello World")       // 显示输出数据 name = input("name = ") //输入数据 help sin  //help 命令名 ,获取帮助信息 apropos logarithm //在帮助文件中搜索logarithm 数值表示 0.5 可以用 .5 表示,科学记数法: 2e-3 2e1 3.12e2, 数组 x = [1,3,4] 等价于 x = [1 3 4] a = (-1+2-4)*8 b = 2^3   //2的三次方(8) %pi //常量pi, %名字,如%e 自然数, %t ...
/* 一百万的随机数排序,费时1秒 ! */ /* c */ #include "stdio.h" #include "time.h" int shu[1000000]; int i,j,k,len; void quick_sort(int left,int right); void swap(int left,int right); void read_file(); void main() { clock_t start, finish; double duration; read_file(); ...
   int i,k;    char str[100];    itoa(i,str,k); // i 为要转换的数字,k 的转换后的进制数,str为保存的字符数组。   // 输入一个十进制数和一个想要转换的进制数,输出由十进制转换后的结果 // 09/10/28 #include "stdio.h" void main() { void change(); printf ("请输入十进制数和基数,用空格分开 \n"); while (1) change(); } void ch ...
以下是一些笔记。 求素数的,我会记录下程序运行的时间,比较不同算法的效率。以后可能会常更新的。如果有最优的算法,我会贴出来的。     #include "stdio.h" //2百万以内 24秒 #include "math.h" void main() { long i,j,k,temp; int f; k=3; printf ("2 "); while (k<2000000) { temp=sqrt(k); f=1; for (i ...
写一些笔记吧。 以下几种简单的排序.   #include "stdio.h" //插入排序 void main() { int i,j,temp,a[11]; printf ("enter data\n"); for (i=1;i<=10;i++) { printf ("a[%d]=",i); scanf ( "%d",&a[i]); //输入数据 } for (i=2;i<=10;i++) //插入排序 for ( ...
import re,urllib aa="http://dict.youdao.com/search?tab=chn&keyfrom=dict.top&q=" print ("input q! to exit ") while 1: word=raw_input(">>>") if word=="q!": exit() else: word=word.replace(' ','+') url=aa+word s=urllib.urlo ...
from google.appengine.ext import db from google.appengine.ext import webapp from google.appengine.api import users from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.ext.webapp import template import os,datetime class data(db.Model): id=db.IntegerProperty(de ...
这篇文章只是简单的增加了一些内容,其中包括之前的那一篇总结。为了防止日后重装系统清空硬盘,贴上网,方便日后查阅。 import sqlite3conn=sqlite3.connect('test.db')cur=conn.cursor()cur.execute("create table test (id int,char1 varchar(10),char2 varchar(10),da text)")cur.execute("insert into test values (1,'a','b','chhfhfhh')")t='aaaa'cur.exe ...
"""用于查看天气的小脚本""" import re,urllib,urllib2 s='http://search.weather.com.cn/static/url.php' body={} n=raw_input('please input your local street tel number: ') print '\n\n' body['cityinfo']=n ss=urllib.urlencode(body) tem=urllib.urlopen(s,ss).read() url=re.fi ...
暑假终于到了,终于有大量的时间学习自己想学的东西。我要学习google app engine ,如果有多余时间,也会学习python的一个WEB框架。以后要写一些笔记。不过这个学期挂了三课。要补考试呀。
Global site tag (gtag.js) - Google Analytics