如果您通过 values
模块使用接口,则数组的元素也需要为 value
,因此它们也可以轻量级。没有这些信息,它将无法确定数组元素的大小。
您可以按以下方式重写一点。
sed -i 's/\(PlayButton-playCircle-kffp_v{.*\)display:inline-block/\1display:none/g' file.css
\(
和 \)
之间的文本将被捕获,可以在替换字符串中引用为 \ 1
。
似乎您打算计算交叉点两组
const x = [1, 3, 7, 4, 9];
const y = [2, 3, 9, 13, 4];
function intersection(setA, setB) {
let _intersection = new Set()
for (let elem of setB) {
if (setA.has(elem)) {
_intersection.add(elem)
}
}
return _intersection
}
const setX = new Set(x);
const setY = new Set(y);
const commonSet = intersection(setX, setY);
console.log(...commonSet); // [3, 9, 4]
删除第二个软件包
声明和解决错误。之后,再次运行。
要在查询结果中显示第一行:
print(db_rows.fetchone())
显示查询的所有结果:
print(db_rows.fetchall())
或
for row in db_rows.fetchall():
print(row)
这应该有效
代码:
list = ['A', 'B', 'C', 'D', 'E']
print(f"The first three items in the list are: {', '.join(list[0:3])}")
输出:
The first three items in the list are: A, B, C
这里的大多数答案给出了一个有用的建议,何时进行单个异步操作,但是有时候,当您需要在数组或其他类似列表的结构中为每个每个条目进行异步操作时,这会出现。诱惑是这样做:
// WRONG
var results = [];
theArray.forEach(function(entry) {
doSomethingAsync(entry, function(result) {
results.push(result);
});
});
console.log(results); // E.g., using them, returning them, etc.
示例:
// WRONG
var theArray = [1, 2, 3];
var results = [];
theArray.forEach(function(entry) {
doSomethingAsync(entry, function(result) {
results.push(result);
});
});
console.log("Results:", results); // E.g., using them, returning them, etc.
function doSomethingAsync(value, callback) {
console.log("Starting async operation for " + value);
setTimeout(function() {
console.log("Completing async operation for " + value);
callback(value * 2);
}, Math.floor(Math.random() * 200));
}
.as-console-wrapper { max-height: 100% !important; }
不起作用的原因是 dosomethingsasync
的回调尚未在尝试使用结果时运行。
因此,如果您有一个数组(或某种形式的列表),并且想对每个条目进行异步操作,则有两个选项:并行执行操作(重叠)或串联(一个接一个地,顺序)。
并行
您可以启动所有这些,并跟踪您期望多少回调,然后在收到许多回调时使用结果:
var results = [];
var expecting = theArray.length;
theArray.forEach(function(entry, index) {
doSomethingAsync(entry, function(result) {
results[index] = result;
if (--expecting === 0) {
// Done!
console.log("Results:", results); // E.g., using the results
}
});
});
示例:
var theArray = [1, 2, 3];
var results = [];
var expecting = theArray.length;
theArray.forEach(function(entry, index) {
doSomethingAsync(entry, function(result) {
results[index] = result;
if (--expecting === 0) {
// Done!
console.log("Results:", JSON.stringify(results)); // E.g., using the results
}
});
});
function doSomethingAsync(value, callback) {
console.log("Starting async operation for " + value);
setTimeout(function() {
console.log("Completing async operation for " + value);
callback(value * 2);
}, Math.floor(Math.random() * 200));
}
.as-console-wrapper { max-height: 100% !important; }
(我们可以消除期望
,只使用 result.length === thearray.length
,但这使我们对 thearray的可能性开放
在呼叫未偿的时候更改...)
请注意我们如何使用 index
for foreach
将结果保存在结果中
在与其所关联的条目相同的位置,即使结果取出订单(由于异步调用不一定要按照启动的顺序完成)。
但是,如果您需要返回 这些结果来自函数呢?正如其他答案所指出的,您不能;您必须接受函数接受并致电回调(或返回a 承诺)。这是回调版本:
function doSomethingWith(theArray, callback) {
var results = [];
var expecting = theArray.length;
theArray.forEach(function(entry, index) {
doSomethingAsync(entry, function(result) {
results[index] = result;
if (--expecting === 0) {
// Done!
callback(results);
}
});
});
}
doSomethingWith(theArray, function(results) {
console.log("Results:", results);
});
示例:
function doSomethingWith(theArray, callback) {
var results = [];
var expecting = theArray.length;
theArray.forEach(function(entry, index) {
doSomethingAsync(entry, function(result) {
results[index] = result;
if (--expecting === 0) {
// Done!
callback(results);
}
});
});
}
doSomethingWith([1, 2, 3], function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value, callback) {
console.log("Starting async operation for " + value);
setTimeout(function() {
console.log("Completing async operation for " + value);
callback(value * 2);
}, Math.floor(Math.random() * 200));
}
.as-console-wrapper { max-height: 100% !important; }
或以下是返回 Promise
的版本:
function doSomethingWith(theArray) {
return new Promise(function(resolve) {
var results = [];
var expecting = theArray.length;
theArray.forEach(function(entry, index) {
doSomethingAsync(entry, function(result) {
results[index] = result;
if (--expecting === 0) {
// Done!
resolve(results);
}
});
});
});
}
doSomethingWith(theArray).then(function(results) {
console.log("Results:", results);
});
当然,如果 dosomethingsasync
传递了我们的错误,我们将使用 recept> recood
拒绝当我们遇到错误时承诺。)
示例:
function doSomethingWith(theArray) {
return new Promise(function(resolve) {
var results = [];
var expecting = theArray.length;
theArray.forEach(function(entry, index) {
doSomethingAsync(entry, function(result) {
results[index] = result;
if (--expecting === 0) {
// Done!
resolve(results);
}
});
});
});
}
doSomethingWith([1, 2, 3]).then(function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value, callback) {
console.log("Starting async operation for " + value);
setTimeout(function() {
console.log("Completing async operation for " + value);
callback(value * 2);
}, Math.floor(Math.random() * 200));
}
.as-console-wrapper { max-height: 100% !important; }
(或者,或者,您可以为返回承诺的 dosomethingsasync
制作包装器,然后执行以下...
) a promise =“ https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/promise/promise/all” rel =“ noreferrer”> promise> Promise> Promise.promise.all
:
function doSomethingWith(theArray) {
return Promise.all(theArray.map(function(entry) {
return doSomethingAsync(entry);
}));
}
doSomethingWith(theArray).then(function(results) {
console.log("Results:", results);
});
如果您知道 DosomethingAsync
将忽略第二个和第三个参数,则可以将其直接传递给 MAP
( MAP
用三个调用其回调争论,但大多数人大多数时候只使用第一次):
function doSomethingWith(theArray) {
return Promise.all(theArray.map(doSomethingAsync));
}
doSomethingWith(theArray).then(function(results) {
console.log("Results:", results);
});
示例:
function doSomethingWith(theArray) {
return Promise.all(theArray.map(doSomethingAsync));
}
doSomethingWith([1, 2, 3]).then(function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value) {
console.log("Starting async operation for " + value);
return new Promise(function(resolve) {
setTimeout(function() {
console.log("Completing async operation for " + value);
resolve(value * 2);
}, Math.floor(Math.random() * 200));
});
}
.as-console-wrapper { max-height: 100% !important; }
请注意, Promise.All
通过所有诺言的结果来解决其承诺,当他们全部解决时,您给予的承诺,或者在 first of时拒绝其承诺您给予的承诺拒绝。
系列
假设您不希望操作并行?如果您想一个接一个地运行它们,则需要等待每个操作完成下一个操作。这是一个可以执行此操作并调用结果的函数的示例:
function doSomethingWith(theArray, callback) {
var results = [];
doOne(0);
function doOne(index) {
if (index < theArray.length) {
doSomethingAsync(theArray[index], function(result) {
results.push(result);
doOne(index + 1);
});
} else {
// Done!
callback(results);
}
}
}
doSomethingWith(theArray, function(results) {
console.log("Results:", results);
});
(由于我们正在串联进行工作,因此我们可以使用 results.push(result)(result)
,因为我们知道我们不会在上面的订单中获得结果。 )
示例:
function doSomethingWith(theArray, callback) {
var results = [];
doOne(0);
function doOne(index) {
if (index < theArray.length) {
doSomethingAsync(theArray[index], function(result) {
results.push(result);
doOne(index + 1);
});
} else {
// Done!
callback(results);
}
}
}
doSomethingWith([1, 2, 3], function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value, callback) {
console.log("Starting async operation for " + value);
setTimeout(function() {
console.log("Completing async operation for " + value);
callback(value * 2);
}, Math.floor(Math.random() * 200));
}
.as-console-wrapper { max-height: 100% !important; }
(或者,再次为 dosomethingsasync
构建一个包装器,可以给您一个承诺,并做下面...)
如果 Dosomething> ,如果您可以使用ES2017+语法(也许与 babel ),您可以使用
ruction> function with for of of of 和
async 等待
等待 :
async function doSomethingWith(theArray) {
const results = [];
for (const entry of theArray) {
results.push(await doSomethingAsync(entry));
}
return results;
}
doSomethingWith(theArray).then(results => {
console.log("Results:", results);
});
例子:
async function doSomethingWith(theArray) {
const results = [];
for (const entry of theArray) {
results.push(await doSomethingAsync(entry));
}
return results;
}
doSomethingWith([1, 2, 3]).then(function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value) {
console.log("Starting async operation for " + value);
return new Promise(function(resolve) {
setTimeout(function() {
console.log("Completing async operation for " + value);
resolve(value * 2);
}, Math.floor(Math.random() * 200));
});
}
.as-console-wrapper { max-height: 100% !important; }
If you can't use ES2017+ syntax (yet), you can use a variation on the
function doSomethingWith(theArray) {
return theArray.reduce(function(p, entry) {
return p.then(function(results) {
return doSomethingAsync(entry).then(function(result) {
results.push(result);
return results;
});
});
}, Promise.resolve([]));
}
doSomethingWith(theArray).then(function(results) {
console.log("Results:", results);
});
示例:示例:
function doSomethingWith(theArray) {
return theArray.reduce(function(p, entry) {
return p.then(function(results) {
return doSomethingAsync(entry).then(function(result) {
results.push(result);
return results;
});
});
}, Promise.resolve([]));
}
doSomethingWith([1, 2, 3]).then(function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value) {
console.log("Starting async operation for " + value);
return new Promise(function(resolve) {
setTimeout(function() {
console.log("Completing async operation for " + value);
resolve(value * 2);
}, Math.floor(Math.random() * 200));
});
}
.as-console-wrapper { max-height: 100% !important; }
...与:
function doSomethingWith(theArray) {
return theArray.reduce((p, entry) => p.then(results => doSomethingAsync(entry).then(result => {
results.push(result);
return results;
})), Promise.resolve([]));
}
doSomethingWith(theArray).then(results => {
console.log("Results:", results);
});
示例:
function doSomethingWith(theArray) {
return theArray.reduce((p, entry) => p.then(results => doSomethingAsync(entry).then(result => {
results.push(result);
return results;
})), Promise.resolve([]));
}
doSomethingWith([1, 2, 3]).then(function(results) {
console.log("Results:", JSON.stringify(results));
});
function doSomethingAsync(value) {
console.log("Starting async operation for " + value);
return new Promise(function(resolve) {
setTimeout(function() {
console.log("Completing async operation for " + value);
resolve(value * 2);
}, Math.floor(Math.random() * 200));
});
}
.as-console-wrapper { max-height: 100% !important; }
您需要检查所读的行,而不是 logFile
实例
with open(NR_log, 'r') as logfile:
lines = [line.strip() for line in logfile.readlines()]
if name_key not in lines:
lst.append('\nError: Script was not successfully executed.\n')
....
您可以使用替换
method ='ffill'
为每个组:
out = df.groupby(level=0).apply(lambda x: x.replace(0, method='ffill'))
print(out)
# Output
0 1 2 3
0 0 0 0 0 0
1 36 19 2 4
2 233 21 2 4
3 505 25 1 4
4 751 27 1 4
5 976 28 1 4
9 976 28 1 4
10 976 28 1 4
11 976 28 1 4
12 976 28 1 4
1 0 40 19 2 4
1 323 18 1 4
2 595 24 1 4
3 844 26 1 4
4 844 26 1 4
5 844 26 1 4
9 844 26 1 4
10 844 26 1 4
11 844 26 1 4
12 844 26 1 4
我认为我设法在Ryan Dawson的帮助下做出了另一种诊断方法。
我确实在当地的后端POD Portforaward并从本地请求,然后发现有一个500错误代码 - &gt;这意味着该请求与API要求不符合:在前端我是错误的上下文类型。
- &gt;因此,入口配置已经处于良好状态。
我们可以使用单元格样式的背景图像属性将图像插入PDFGrid中。它正确地在网格单元中添加了图像。请找到以下代码段,
PdfDocument document = PdfDocument();
//Create a PdfGrid class
PdfGrid grid = PdfGrid();
//Add the columns to the grid
grid.columns.add(count: 3);
//Add header to the grid
grid.headers.add(1);
//Add the rows to the grid
PdfGridRow header = grid.headers[0];
header.cells[0].value = 'Employee ID';
header.cells[1].value = 'Employee Name';
header.cells[2].value = 'Salary';
//Add rows to grid
PdfGridRow row = grid.rows.add();
row.cells[0].value = 'E01';
row.cells[1].value = 'Clay';
row.cells[2].value = '\$10,000';
final PdfImage image = PdfBitmap(File('E://logo.png').readAsBytesSync());
row = grid.rows.add();
row.height = 30;
row.cells[0].value = 'E02';
row.cells[1].style.backgroundImage = image;
row.cells[1].value = "";
row.cells[2].value = '\$12,000';
row = grid.rows.add();
row.cells[0].value = 'E03';
row.cells[1].value = 'John';
row.cells[2].value = '\$14,000';
//Draw the grid
grid.draw(
page: document.pages.add(), bounds: const Rect.fromLTWH(0, 0, 0, 0));
File('E://Flutter/GridOutput.pdf').writeAsBytes(document.save());
document.dispose();
ug:
https://help.syncfusion.com/flutter/pdf/working-with-tables
如果您在Django设置中已安装的应用程序中注册应用程序名称,则可以轻松处理大多数迁移和其他方面的其他内容,您可以从应用程序名称的文件夹中分支。
制作一个名为应用程序的单独目录,您可以将所有应用程序放置在应用程序主管中
我建议您
from app.some_new_app_name.models import MyModel
from app.some_new_app_name_2.models import MyModel2
尝试以下操作:
function scoreToGrade() {
var cellsChecked = ['AF2', 'AG2', 'AH2'];
var sheet = SpreadsheetApp.getActiveSheet();
for (var i = 0; i < cellsChecked.length; i++) {
var value = sheet.getRange(cellsChecked[i]).getDisplayValue();
console.log(value);
if (value == '#VALUE!') {
// do something
console.log('Not blank ' + value);
sheet.deleteColumn(sheet.getRange(cellsChecked[i]).getColumn());
} else {
// do something else
console.log('is another value ' + value);
}
}
}
最简单的方法是使用slice note
.loc
以及您与.drop
的调用一起删除任何特定不需要的列:创建数据
.loc
.loc < /code>并相当简单地删除,请使用
.loc
执行切片,然后drop
从那里您不想要的任何东西。使用索引
,如果要在索引中尽可能高效地工作,则可以将
index.slice_indexer
与.drop
一起使用,这样您就不会创建临时子集您的数据(就像我们上面所做的那样):The easiest way will be to use slice notation
.loc
as you demonstrated along with a call to.drop
to remove any specific unwanted columns:Create data
.loc
and droppingFairly straightforward, use
.loc
to perform your slicing thendrop
anything you don't want from there.Working With the Index
If you want to work as efficiently as possible with the index, you can use
Index.slice_indexer
along with.drop
so that you don't create temporary subsets of your data (like we did above):从数据框架中选择特定列