L******3 发帖数: 18 | 1 用Python实现了一个简单的class,如下:
class Multiply:
def __init__(self):
self.a = 6
self.b = 5
def multiply(self):
c = self.a*self.b
print 'The result of', self.a, 'x', self.b, ':', c
return c
def multiply2(self, a, b):
c = a*b
print 'The result of', a, 'x', b, ':', c
return c
用C写了个一个程序去instantiate上面class的实例,并调用两个method,一切都没什
么问题。可是发现,当我在python script的开头import一些module时,例如,import
httplib,C程序里的PyImport_Import这个script时会失败,返回NULL。import sys时
就没问题。
求版上大牛帮忙,谢谢 | l*********s 发帖数: 5409 | 2 sys is internal module, while httplib is external, probably the path is not
set up properly so the task cannot locate it. | L******3 发帖数: 18 | 3 谢谢回答先。
不过,我加了char * path = Py_GetPath(),httplib的path在sys.path里啊。
not
【在 l*********s 的大作中提到】 : sys is internal module, while httplib is external, probably the path is not : set up properly so the task cannot locate it.
|
|