我一直在寻找许多与我类似的问题,但找不到解决方案。
我正在使用请求来执行 POST 请求。我在请求中尝试了很多组合,但没有返回 201 ok。
这是我的代码:
import json
import requests
if __name__ == '__main__':
headers = {'content-type' : 'application/json'}
url = "http://myserver/ext/v3.1/test_device"
message = {"atribute_a": "value", "atribute_b": "valueb"}
params = {"priority":"normal"}
r = requests.post(url, params=params, headers=headers, data = json.dumps(message) )
print(r)
Run Code Online (Sandbox Code Playgroud)
我也试过没有 json.dumps 但它也给了我 400 个错误的请求。我还尝试将参数直接添加到 url 中,例如:...?priority=normal但没有成功。
我正在使用 SD 卡,需要每 5 分钟创建一个新的 csv 文件。
因此,每当我的计时器到期时,我都会创建一个名为“newfile0.csv”、newfile1.csv“的文件,依此类推。它会按预期工作,直到我到达“newfile10.csv”。此时,我开始来获取函数FR_INVALID_NAME的返回值f_open。
我已经尝试过不同的方法来创建包含文件名的字符串。我在调用之前也检查了字符串内容f_open,结果没问题。
我将在这里放置一些代码。
char *file_name = (char*)calloc(17,sizeof(char));
if (file_name != NULL )
printf("error");
char *number = (char*)calloc(10,sizeof(char));
if (number != NULL )
printf("error");
if (count_files < MAX_NO_FILES){
count_files++;
strcat(file_name, "lewfile");
itoa(file_name, number);
strcat(file_name, number);
strcat(file_name, ".csv");
printf("CONCATENATED STRING: %s", file_name);
fileSystemResult = f_open(&fileObject[count_files], file_name, FA_CREATE_ALWAYS | FA_WRITE);
if (fileSystemResult != FR_OK)
printf("error creating the file: %d \n\r",fileSystemResult );
Run Code Online (Sandbox Code Playgroud)
我可能错过了什么提示吗?