好的,我有一些python代码可以打开一个文件->;处理它->;并将数据写入其他文件。你知道吗
def ELECrypt(myFile, outFile, code):
Code = list(bytes(code,'utf-8'))
with open(myFile, 'rb') as bFil:
with open(outFile, 'wb') as bOutFil:
while True :
data = bytearray(bFil.read(CHUNK_SIZE))
if not data: break
processIt(data, Code)
bOutFil.write(data)
它工作得很好,但是太慢了。 所以,我编写了一个C++程序,它做了类似的事情,我想知道是否可以用Python
调用它。#include <iostream>
#include <fstream>
using namespace std;
int CHUNK_SIZE = 1*1024*1024;
void ELECrypt(ifstream& myFile, ofstream& outFile, unsigned char Code[], int CodeLen){
unsigned char* fChunk = new unsigned char[CHUNK_SIZE];
int readCount;
while (myFile.read((char *)fChunk, CHUNK_SIZE) || myFile.gcount() > 0)
{
...Processing a data block
outFile.write((char *)fChunk, myFile.gcount());
}
delete [] fChunk;
}
是的,我知道可能有很多工作要做,但我甚至找不到哪里可以阅读python可以传递给c++扩展的参数
目前没有回答
相关问题 更多 >
编程相关推荐