
Embedding Calls 。书上举了一个 C 调用 Python 的简单示例:
#include <Python.h>
...
Py_Initialize( );
PyRun_SimpleString("x = brave +
sir
+ robin");
Python
Python
Python
Python 程序结构
程序包括模块;模块包括语句;语句包括表达式;表达式处理对象。
类型与操作 ——
——
——
—— 我 的 Python
Python
Python
Python 笔记
基本变量类型
Number ,数字: 8 。
String ,字符串:
’
test ’
List ,列表: [1,2,4,5]
Dictionaries ,字典: {'food': 'spam', 'taste': 'yum'}
Tuple ,元组: (1,'spam', 4, 'U')
File 文件: myfile = open('eggs', 'r')
其它类型: Sets, types, None, Booleans
数字简介
print 3.14 * 2
#math
import math
print math.pi
#random
import random
print random.random()
print random.random()
print random.choice([1,2,3,4])