摘要: 定义函数>>> def fib(n): # write Fibonacci series up to n... """Print a Fibonacci series up to n."""... a, b = 0, 1... while a < n:... print(a, end=' ')... a, b = b, a+b... print()...>>> # Now call the function we just defined:... fib(2000)0 1 1 阅读全文
posted @ 2012-12-28 00:17 fff8965 阅读(279) 评论(0) 推荐(0) 编辑
摘要: if>>> x = int(input("Please enter an integer: "))Please enter an integer: 42>>> if x < 0:... x = 0... print('Negative changed to zero')... elif x == 0:... print('Zero')... elif x == 1:... print('Single')... else:... print('More')...Moref 阅读全文
posted @ 2012-12-27 23:56 fff8965 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 动态数组,可以存储不同数据类型>>> a = ['spam', 'eggs', 100, 1234]>>> a['spam', 'eggs', 100, 1234]和string一样,支持索引,+,*>>> a[0]'spam'>>> a[3]1234>>> a[-2]100>>> a[1:-1]['eggs', 100]>>> a[:2] + ['bacon' 阅读全文
posted @ 2012-12-27 23:45 fff8965 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 多行文本以\结尾,换行还是要用\nhello = "This is a rather long string containing\n\several lines of text just as you would do in C.\n\ Note that whitespace at the beginning of the line is\ significant."print(hello)多行原格式文本用"""或者'''围绕。里面的换行就是换行print("""\Usage: thin 阅读全文
posted @ 2012-12-27 23:34 fff8965 阅读(204) 评论(0) 推荐(0) 编辑
摘要: python默认的除法运算时浮点运算如:1/3 0.33333333333如果想要整除结果,要用//如:1//3 0 阅读全文
posted @ 2012-12-27 23:14 fff8965 阅读(284) 评论(0) 推荐(0) 编辑
摘要: import sitesite.getusersitepackages()上面代码可以得到import的导入包文件夹,只要把自己的py文件放到这个文件夹里,那么每个.py文件执行的时候都会导入 阅读全文
posted @ 2012-12-27 23:10 fff8965 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.csdn.net/tuwen/article/details/2182838__stdcall,__cdecl,_cdecl,_stdcall,。__fastcall,_fastcall 区别简介1.今天写线程函数时,发现msdn中对ThreadProc的定义有要求:DWORD WINAPI ThreadProc(LPVOID lpParameter);不解为什么要用WINAPI宏定义,查了后发现下面的定义。于是乎需要区别__stdcall和__cdecl两者的区别; #define CALLBACK __stdcall#define WINAPI __stdca 阅读全文
posted @ 2012-12-27 21:32 fff8965 阅读(182) 评论(0) 推荐(0) 编辑
摘要: cdecl格式的调用要用 p = ctypes.cdll.LoadLibrary('a.dll') 或者 p = ctypes.CDll('a.dll')stdcall用 p = ctypes.windll.LoadLibrary('a.dll') 或者 p = ctypes.WinDll('a.dll')一般c++用的是__cdecl,windows里大都用的是__stdcall(API), win32中的CALLBACK是__stdcall 阅读全文
posted @ 2012-12-27 21:29 fff8965 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 导入ctypes以后cdll.msvcrt为标准c的函数库,可以调用标准C里的函数,如from ctypes import *libc = cdll.msvcrtprint(libc.printf)print(libc.time(None))print(libc.sin(2))windll代表windows的一些常用dll,如from ctypes import *libc = cdll.msvcrtprint(hex(windll.kernel32.GetModuleHandleA(None))) 阅读全文
posted @ 2012-12-27 19:50 fff8965 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 转自:http://blog.csdn.net/xust999/article/details/6073299用了些时间学习了下LIB和DLL的一些知识,看了很多人的文章,也自己总结了一些,出于自己的理解...1、LIB与DLL文件的区别2、静态编译和动态链接的23事...3、*.h、*.lib/*.a、*.dll 之间的关系4、为无LIB的DLL制作LIB函数符号输入库 5、调用dll文件 <这里分C版接口和C++版接口,要弄清概念>6、DEV-C++编写dll文件的几个知识点1、DLL是一个完整的程序,中文名称为“动态链接库”,DLL中包含的主要有三块内容:1.全部变量 2.函 阅读全文
posted @ 2012-12-27 17:41 fff8965 阅读(209) 评论(0) 推荐(0) 编辑