const input = '[ { "name": "DI", "children": [ { "name": "t", "children": [ { "name": "tID", "ir": true, "is": false }, { "name": "tTime", "ir": false, "is": false } ], "ir": false, "is": false }, { "name": "i", "idx": 0, "children": [ { "name": "idu", "ir": false, "is": false }, { "name": "il", "ir": false, "is": false }, { "name": "ibId", "children": [ { "name": "ib1", "ir": false, "is": false }, { "name": "ib2", "ir": false, "is": false } ], "ir": false, "is": false } ], "ir": false, "is": false } ] } ]'
// console.log(JSON.parse(input))
const convertToObject = (data) => {
const { name, children, ...others } = data
if(!children) return others;
return children.reduce((acc, d) => {
acc[d['name']] = convertToObject(d);
return acc;
}, {})
}
console.log(convertToObject({ 'children': JSON.parse(input) }))
您应该只是在每行的开头而不是末端打印线路断裂。这样,您也无需考虑最后一行!
您还可以摆脱索引的增加。
for el in applicants: # write the name of the worker to the text file
if index == 0: # this is the first line no need for a line break
file.write(el)
# increment the index for later iterations
index += 1
else: # these are the middle lines and it is essential to break a line
file.write("\n"+el)
尝试以下操作:
div_containing_radio = driver.find_element(by=By.XPATH,"//div[starts-with(@class, 'ProductVariants__PriceContainer-sc-1unev4j-9 jjiIua')]/following-sibling::text()")
您可以使用Google的“ Cloud Vision API(用于图像): https://cloud.google.com/vision “ 和“视频智能API(用于视频): https://cloud.google.com/video-intelligence/docs/docs“ 。
视频智能API也可以从字节流处理图像。
构建一个Firebase功能,分析使用这些API发布媒体。
从这里构建其余逻辑。找到一种方法来检测他们的兴趣,节省他们的兴趣。
问题在您的循环中。更具体地说,您需要在使用它之前声明变量i。如果您像以下片段一样更改代码,则您的代码正常工作:
let nums = [2, 1, 3, 4, 5, 6];
function sortArray(nums) {
let arr = new Array();
let smallest_index;
for (let i = 0; i < nums.length; i++) {
smallest_index = find_smallest(nums);
arr.push("5");
}
return arr;
}
function find_smallest(arr) {
let smallest = arr[0];
let smallest_index = 0;
for (let i = 1; i < arr.length; i++) {
if (arr[i] < smallest) {
console.log("this");
smallest = arr[i];
smallest_index = i;
}
}
return smallest_index;
}
console.log(sortArray(nums));
唯一的区别是
for (let i = 1; ...
使用
for (i = 1; ...
您可以在循环中建立复杂的 q
对象 - 使用 q_obj | = q(...)
with或
selections = ['Who', 'What']
or_expr = Q()
for selection in selections:
or_expr |= Q(question__startswith=selection)
MyModel.objects.filter(or_expr)
尝试使用PostgreSql /a>函数:
SELECT d.referenca,
paketi.id_upnik,
DATE(zadnji_klic) AS zadnji_klic,
DATE(datum_zadnjega_posiljanja_sms) AS datum_zadnjega_posiljanja_sms,
DATE(zadnji_datum_opomina_maila) AS zadnji_datum_opomina_maila,
DATE(datum_dopisa_dolznika) AS datum_dopisa_dolznika,
GREATEST(zadnji_klic,
datum_zadnjega_posiljanja_sms,
zadnji_datum_opomina_maila,
datum_dopisa_dolznika) AS datum_zadnji_kontakt
FROM QUERIES AND SUBQUERIES
在
现在,原始田地具有“有”用于检查其存在的方法
C ++。
这与包括非实验proto3可选支持的相同版本是。
默认情况下启用了proto3的可选字段,不再需要
-experimention_allow_proto3_optional标志。
在该版本之前,一个人可以使用生成的 _case ()
函数检测设置了哪个单字段。
您可以在开始时使用 get_lock
添加查询 do get_lock('lockname',30)
在开始时, do resable_lock('lockname')之后询问。
因此,当用户1启动查询时,将设置锁定 lockname
,并且仅在完成后将其释放,如果用户2启动脚本 do get_lock('lockname',30)
等待继续释放的锁。
它以@dawg描述的方式工作,因此我将其标记为解决方案。
@biffen的建议也在工作
通过bash中的文件内容循环
代码根据他的回答:
get_name () {
name=$(awk -F ";" '{print $2 }' list.csv | sed 's/"//g')
while read p; do
echo "Hello" $p
done < $name
}
get_name
要并行运行API调用并等待所有这些调用,您需要将代码更改为遵循
if (isCall2 && responses) {
await Promise.all(responses.map(async ({ code }, index) => {
await getAxiosService().post("http://sample2.com", {
code,
});
}));
}
完整代码:
export const createAllProducts =
({ data = null, isCall2 = false }) =>
async (dispatch) => {
try {
dispatch({
type: constants.CREATE_ALL_PRODUCTS_REQUEST,
});
const requests = data.map(({ test, name }) => {
return getAxiosService().post("http://sample.com", {
test,
name,
});
});
const responses = await Promise.all(requests);
if (isCall2 && responses) {
await Promise.all(responses.map(async ({ code }, index) =>{
await getAxiosService().post("http://sample2.com", {
code,
});
}));
}
dispatch({
type: constants.CREATE_ALL_PRODUCTS_SUCCESS,
});
} catch (error) {
dispatch({
type: constants.CREATE_ALL_PRODUCTS_FAILURE,
});
}
};
发布前选项请求并不是您的浏览器。
检查此 angular $ http是发送选项,而不是put/post/post < /a>
结论,您必须在Spring引导中修复CORS策略,以及Spring Boot如何处理SecurityConfiguration中的选项请求。您可以在问题中添加代码的这一部分吗?
您可以做到这一点:
这对应于景观中97.22%的平板电脑。对于与电话或平板电脑相对应的尺寸,有更多信息。
You can do this:
This corresponds to 97.22% of tablets in landscape. For sizes corresponding to phones or tablets there is more info here.
如何知道在Android中的平板电脑或电话