background:
course design involves calling several compiled .exe executables at the back end. Calling hello.exe directly in test.py is tested to be fine, but calling hello.exe in django views.py fails:
"hello.exe" is not an internal or external command, nor is it a runnable program or batch file.
related environment:
python 3.5,2.1django, IDE: PyCharm.
related code:
test.py
import os
def ccpp():
main="hello.exe"
f = os.popen(main)
data = f.readlines()
f.close()
return data
if __name__=="__main__":
print(ccpp())
hello.cpp
-sharpinclude<iostream>
void test()
{
std::cout<<"hello"<<std::endl;
}
int main()
{
test();
return 0;
}
views.py
def test(ruquest):
...
main="hello.exe"
f = os.popen(main)
data = f.readlines()
f.close()
...
test.py views.py hello.cpp hello.exe are all in the same level directory.
the result of calling directly in test.py is as follows
views.py test()