python31与C交互
1.c调用python:
实例代码:
main.c调用test.py的
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//main.c
#include <windows.h>
#include <python.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
Py_Initialize() ;//initialize the python system
PyObject * py= PyImport_ImportModule("test");
Py_Finalize();//Finalize the python system
}
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
相关文档:
python的egg文件有点像java中的jar文件,是一个工程打包文件,便于安装部署,仅此一点,给多少pythoner带来了多少激动。
如何制作egg文件呢?see官方文档http://peak.telecommunity.com/DevCenter/PythonEggs,
到http://pypi.python.org/pypi/setuptools下载setuptools包,然后安装:
python setup.py
1.制作egg文件
......
软件准备:
1.eclipse开发包,下载地址:http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR2/eclipse-java-galileo-SR2-win32.zip
2.pydev插件,下载地址:http://sourceforge.net/projects/pydev/files/pydev/Pydev%201.5.4/org.python.pydev.feature-1.5.4.2010011921 ......
本文介绍在GNU/Linux环境下一个C程序由源代码到程序,到加载运行,最后终止的过程。同时以此过程为载体,介绍GNU/Linux平台下软件开发工具的使用。
本文以我们最常见的hello, world!为例:
#include <stdio.h>
main ()
{
printf(“hello, world!\n” ......
C库函数
字符串函数
函数名
函数原型
功能
返回值
包含头文件
strcat
char *strcat(char *st1, char *str2)
把str2连接到str1后面
str1
string.h
strchr
char *strchr(char *str, int ch)
找出str指向的字符串中第一次出现字符串ch的位置
指向该位置的指针,未找到则返回空指针
......
下面列出Python正则表达式的几种匹配用法:
1.测试正则表达式是否匹配字符串的全部或部分
regex=ur"" #正则表达式
if re.search(regex, subject):
do_something()
else:
do_anotherthing()
2.测试正则表达式是否匹配整个字符串
regex=ur"\Z" #正则表达式末尾以\ ......