Boost Python ʵÏÖCµ÷ÓÃpython´íÎó½â¾ö·½·¨
ÓÉÓÚBoost Python¸ú²»ÉÏPython°æ±¾¸üУ¬ÈçÏ·½·¨µ÷ÓÿÉÄܲúÉúTypeError: 'NoneType' object does not support item assignmentÒì³£¡£
Boost PythonÎĵµÖÐÀý×Ó¿ÉÄܲúÉúÒì³£¡£
Py_Initialize();
object main_module = import("__main__");
object main_dict = main_module.attr("__dict__");
try{
object result = exec("result = 5 + 5",main_dict);
int five_squared = extract<int>(main_dict["result"]);
cout<<"extract value : "<<five_squared<<endl;
cin>>ij;
}
catch(error_already_set){
PyErr_Print();
cin>>ij;
}
¿ÉÒÔÈçÏ·½·¨½â¾ö
Py_Initialize();
object main_module = import("__main__");
object main_dict = main_module.attr("__dict__");
try{
handle<> ignored((PyRun_String(
"result = 5 ** 2"
, Py_file_input
, main_dict.ptr()
, main_dict.ptr())
));
int five_squared = extract<int>(main_dict["result"]);
cout<<"extract value : "<<five_squared<<endl;
cin>>ij;
}
catch(error_already_set){
PyErr_Print();
cin>>ij;
}
Boost PythonÖÐÖ´Ðбí´ïʽº¯ÊýÒ²¿ÉÒÔÕý³£ÔËÐС£
Py_Initialize();
object main_module = import("__main__");
object main_dict = main_module.attr("__dict__");
try{
object result = eval("5 + 5",main_dict);
int five_squared = extract<int>(result);
cout<<"extract value : "<<five_squared<<endl;
cin>>ij;
}
catch(error_already_set){
Ïà¹ØÎĵµ£º
Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable.
There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various man ......
client:
import socket, sys
if __name__ == '__main__':
#´¦Àí²ÎÊý
argv = sys.argv
if (len(argv)!=3) or (len(argv)==2 and argv[1]=='/?'):
print '>>>Useage:', argv[0], '<address> < ......
¿Í»§¸øÒ»¶ÑͼƬҪ´«µ½ºǫ́£¬Í¼Æ¬Ì«´óÁË£¬ÉϰÙÕÅͼÓÃphotoshop¸ÄÌ«Âý£¬¾ÍÏëµ½ÓÃpythonд¸ö¼òµ¥µÄÅú´¦Àí¡£¹¦Äܼòµ¥¾ÍÊǰÑÔͼ°´±ÈÀýËõС£¬´úÂë¸ü¼òµ¥ 20¶àÐС£
# -*- coding: cp936 -*-
import Image
import glob, os
#ͼƬÅú´¦Àí
def timage():
for files in glob.glob('D:\\1\\*.JPG'):
filepath,filena ......
#coding=utf-8
from newtest.wiki.models import WiKi
from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
def index(request, pagename=""):
"""ÏÔʾÕý³£Ò³Ã棬¶ÔÒ³ÃæµÄÎÄ×Ö×öÌØÊâµÄÁ´½Ó´¦Àí"""
......
/********************************************************************
*ɾ³ýC/C++×¢ÊÍ
**********************************************************************/
#include <stdio.h>
//×¢Òâ
//1.¶Ô/****/µÄ´¦Àí
//2.Òª±£ÁôË«ÒýºÅÖ®¼äµÄÄÚÈÝ£¬Èçchar* test = "/*i am not comment */";
//3.¶ÔÓ ......