&引用;属性错误:';模块';对象没有属性';argv'&引用;使用Python.h时

&引用;属性错误:';模块';对象没有属性';argv'&引用;使用Python.h时,python,c++,python-c-api,python-embedding,Python,C++,Python C Api,Python Embedding,在处理Python.h时,我遇到了以下错误: AttributeError: 'module' object has no attribute 'argv' C++代码: #include "stdafx.h" #include "C:/Python27/include/Python.h" #include <iostream> using namespace std; int main() { Py_Initialize(); PyRun

在处理Python.h时,我遇到了以下错误:

AttributeError: 'module' object has no attribute 'argv'
C++代码:

#include "stdafx.h"  
#include "C:/Python27/include/Python.h"  
#include <iostream>  

using namespace std;  


int main()  
{
    Py_Initialize();
    PyRun_SimpleString("import sys\nprint sys.argv[0]");
}

我缺少什么?

从概念上讲,
sys.argv
应该包含调用Python时使用的参数(以及在下面调用的参数)。但是,如果它被称为这样,它应该有什么呢

如果需要,可以将调用程序的
argv
加载到
sys

int main(int argc, char **argv)
{
    Py_Initialize();
    PySys_SetArgv(argc, argv);
    PyRun_SimpleString("import sys\nprint sys.argv");
}
给予

另请参见
Py\u SetProgramName

int main(int argc, char **argv)
{
    Py_Initialize();
    PySys_SetArgv(argc, argv);
    PyRun_SimpleString("import sys\nprint sys.argv");
}
localhost-2:argv $ ./a.out
['./a.out']
localhost-2:argv $ ./a.out arg0 17
['./a.out', 'arg0', '17']