我正在尝试使用tweepy实时流创建一个实时流Flask应用...但是,我看到的为我的应用发送推文数据的唯一方法是写入/读取文件...有什么办法吗?使其更有效?
写作示例:
#include <iostream>
void printArray(int* a, int arraySize){
for(int i = 0; i < arraySize; i++)
std::cout << a[i] << " ";
std::cout << std::endl;
}
int currentSum(int* a, int arraySize){
int sum = 0;
for(int i = 0; i < arraySize; i++)
sum += a[i];
return sum;
}
void printAll(int* a, int arraySize, int k, int beg){
for(int i = beg; i < arraySize; i++){
if(currentSum(a, arraySize) == k)
printArray(a, arraySize);
else{
a[i]++;
printAll(a, arraySize, k, beg+1);
a[i]--;
}
}
}
int main(){
int k = 3; //array must add up to k, exactly
int arraySize = 4;
int* a = new int[arraySize];
for(int i = 0; i < arraySize; i++)
a[i] = 0;
printAll(a, arraySize, k, 0);
}
阅读示例:
def on_data(self, data):
json_content = json.loads(data)
with open('tweets.txt','w', encoding='utf-8') as file:
file.write(json_content['text'])
有什么方法可以使其直接连接?