您可以使用类似的放置变量:
woocommerce_form_field( 'cstm_leeftijd'.$i, array(
'type' => 'select',
'class' => array('my-field-class form-row-first'),
'label' => __('Leeftijd bij start Summer Camp'),
'required' => true,
'placeholder' => __( 'Selecteer', 'njengah' ),
'options' => array(
'4' => __( '4', 'njengah' ),
'5' => __( '5', 'njengah' ),
'6' => __( '6', 'njengah' ),
'7' => __( '7', 'njengah' ),
'8' => __( '8', 'njengah' ),
'9' => __( '9', 'njengah' ),
'10' => __( '10', 'njengah' ),
'11' => __( '11', 'njengah' )
)), $checkout->get_value( 'cstm_leeftijd'.$i ));
- 转到Python文件夹
python36/lib/site-packages/scipy/
- open
__ init __. py
更改:
from scipy._lib._testutils import PytestTester
to:to:
from scipy._lib.test__testutils import PytestTester
它在我的Windows 7上工作
就我而言,删除 Yarn.lock
文件解决了问题。
这可能是由于Elasticsearch依赖性不兼容的版本。来自看来您似乎需要7.10或7.16,但是您具有7.6依赖关系。还要检查服务器版本以确保。
首先,您无需设置 primary_key
字段,因为Django会为您做到这一点。因此,您最好分别从3个模型中删除 project_id
, site_id
, sigsion> sistienment_id
字段。
并且在 createNewprojetserial
中存在一些错误。
site_name
,分配了_to_id
字段应为 read_only
,如果您无法使用相关对象上传,则需要其他字段才能接收有效载荷。
class CreateNewProjetSerial(serializers.ModelSerializer):
site_name = ProjectSiteSerializer(many=True, read_only = True)
assigned_to_id = AssignedUserSerializer(many=True, read_only = True)
site_names = serializers.ListField(
child = serializers.CharField(), write_only = True)
user_ids = serializers.ListField(
child = serializers.IntegerField(), write_only = True)
class Meta:
model = Project
fields = ['site_name','project_name','assigned_to_id', 'site_names', 'user_ids']
def create(self, validated_data):
site_names = validated_data.pop('site_names')
user_ids = validated_data.pop('user_ids')
new_project = Project.objects.create(**validated_data)
for site_name in site_names:
new_project_site = ProjectSite.objects.create(project_id=new_project, site_name=site_name)
for user_id in user_ids:
Assignment.objects.create(assigned_to_id__id=user_id, site_id=new_project_site)
return new_project
在前端,请像以下内容上传。
{
"site_names": ["site1", "site2"],
"project_name": "test_project",
"user_ids": [2, 3]
}
我能想到的最简单的解决方案是将您执行的每个操作保存到任务对象中,并将每个对象添加到列表中。迭代完成后,请将列表传递给 tasks#wherallsuccess(collection> task; task; task; task; tasks)您可以看到的方法在以下代码中:
List<Task<DocumentSnapshot>> tasks = new ArrayList<>();
for (String id : ids) {
Task<DocumentSnapshot> task = db.collection("Collection").document(id).get();
tasks.add(task);
}
Tasks.whenAllSuccess(tasks).addOnSuccessListener(new OnSuccessListener<List<Object>>() {
@Override
public void onSuccess(List<Object> list) {
//Do what you need to do with your list
for (Object object : list) {
ModelClass mc = ((DocumentSnapshot) object).toObject(ModelClass.class);
}
}
});
每个其他答案都解释了为什么这实际上是一种不错的所需行为,或者为什么您无论如何都不需要这个。我的是为那些想要行使自己的权利将语言屈服于自己的意志而不是相反的顽固的人。
我们将使用装饰器“修复”此行为,该行为将复制默认值,而不是重复使用其默认值的每个位置参数相同的实例。
import inspect
from copy import deepcopy # copy would fail on deep arguments like nested dicts
def sanify(function):
def wrapper(*a, **kw):
# store the default values
defaults = inspect.getargspec(function).defaults # for python2
# construct a new argument list
new_args = []
for i, arg in enumerate(defaults):
# allow passing positional arguments
if i in range(len(a)):
new_args.append(a[i])
else:
# copy the value
new_args.append(deepcopy(arg))
return function(*new_args, **kw)
return wrapper
现在,让我们使用此装饰器重新定义我们的功能:
@sanify
def foo(a=[]):
a.append(5)
return a
foo() # '[5]'
foo() # '[5]' -- as desired
对于采用多个参数的功能,这尤其整洁。比较:
# the 'correct' approach
def bar(a=None, b=None, c=None):
if a is None:
a = []
if b is None:
b = []
if c is None:
c = []
# finally do the actual work
重要的是
# the nasty decorator hack
@sanify
def bar(a=[], b=[], c=[]):
# wow, works right out of the box!
要注意,如果您尝试使用关键字args,则上述解决方案会破裂,例如:
foo(a=[4])
可以调整装饰器以允许这样做,但是我们将其作为读者的练习;)
对索引器进行范围和多线程,以在并行模式下支持重新索引。它通过索引器的维度并行,并跨多个线程执行,从而减少了处理时间。
也许可以帮助:)
当您创建 pendingIntent
时,
PendingIntent pendingIntent = PendingIntent.getBroadcast(ReminderActivity.this, MID,intent1, 0);
请检查您不会传递相同的请求代码 MID
。在这种情况下,Android“重用”以前创建的未决意图,这就是为什么您只会看到最新的通知而不是几个通知。
避免问题的最简单方法似乎是传递不同的请求代码(或其他参数,例如不同的 setAction(...)
- 参见下面的链接)。
有关更多信息,请浏览一下Android如何比较即将出现的意图: >
此方法可在某些版本的猫鼬上使用,因此您可以尝试以下方法:
await Booking.findById({ _id })
.populate({
path: 'routeId',
populate: {
path: 'Bus',
model: Bus,
select:"-_id busNumber"
}
})
您可以简单地列出所需字段,然后仅在最终结果行中将它们推出以显示,例如,
const auditReportConsol = () => {
const folder = DriveApp.getFolderById('1Y2QgLbHncLzPDe-UCD6WizSNnHkjkt4z');
const forms = folder.getFilesByType(MimeType.GOOGLE_FORMS);
const FIELD_LIST = [7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59,61,63,65,67,69];
const rows = [];
while (forms.hasNext()) {
const file = forms.next();
const form = FormApp.openById(file.getId());
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++) {
var formResponse = formResponses[i];
var itemResponses = formResponse.getItemResponses();
var row = [];
// Pick required items
itemResponses.map( (index, item) => FIELD_LIST.indexOf(index) >=0 && row.push(item.getResponse()))
}
}
// Save rows array into sheet
var ss = SpreadsheetApp.openById('1Qlv4v5dU6caBnRfa4Z58OBnoT0g3uFEmKewTENsBOLo');
var sheet = ss.getActiveSheet();
sheet.clear();
sheet.getRange(1,1, rows.lengths, rows[0].length)
}
我也可能建议将表单/名称作为第一列以区分不同的表单:
row.unshift(form.getTitle())
方法 timetuple()
是一个实例方法,您无法在 datetime
类上调用,喜欢
now = datetime.now()
tt = now.timetuple()
timestamp = round(time.mktime(tt))
获取时间戳,只需使用 dateTime.timestamp()
now = datetime.now()
print(round(now.timestamp()))
该警告是从该 summarise_all(平均值)
引起的,不仅可以在 var1
&amp上计算平均值。 var2
,但在状态
&amp; country
。如果要保留状态
和 country
作为分组列,则应将它们放入 group_by()
:
library(dplyr)
df %>%
group_by(county, state, country,
period = cut(year, seq(2011, 2021, by = 5), right = FALSE)) %>%
summarise_all(mean) %>%
ungroup()
# # A tibble: 10 × 7
# county state country period year var1 var2
# <chr> <chr> <chr> <fct> <dbl> <dbl> <dbl>
# 1 a A AA [2011,2016) 2013 33.1 69.7
# 2 a A AA [2016,2021) 2018 24.7 73.6
# 3 b B BB [2011,2016) 2013 27.6 72.3
# 4 b B BB [2016,2021) 2018 24.7 83.1
# 5 c C CC [2011,2016) 2013 38.7 75.7
# 6 c C CC [2016,2021) 2018 22.8 66.8
# 7 d D DD [2011,2016) 2013 33.8 72.2
# 8 d D DD [2016,2021) 2018 20.0 83.7
# 9 e E EE [2011,2016) 2013 14.9 71.0
# 10 e E EE [2016,2021) 2018 19.6 70.4
如果分组列是简单的 County
和期间
,其他分类变量在每个组中都是唯一的,您可以通过将第一个值留在执行 first()时将它们保留下来。代码>总结()。
df %>%
group_by(county,
period = cut(year, seq(2011, 2021, by = 5), right = FALSE)) %>%
summarise(across(!where(is.numeric), first),
across( where(is.numeric), mean)) %>%
ungroup()
您可以使用降低
来知道 0,5
不是有效的数字,因此您必须用,
。<<<<
。 /代码>为了正确解析
const data= [
{ "id": 1,
"exercise": "1.1",
"name": "Session one",
"hours": "1"
},
{ "id": 2,
"exercise": "1.2",
"name": "Session two",
"hours": "4"
},
{ "id": 3,
"exercise": "1.3",
"name": "Session three",
"hours": "0,5"
}
]
const total = data.reduce((res, {hours}) => res + parseFloat(hours.replace(',', '.')), 0.)
console.log(total)
这里有多个问题。首先,这不是列表:
那只是一个字符串。如果您想要一个列表,请写:
或:(
我已经删除了报价,因为它们不是必需的,但是您可以编写
'chad'
,而不是chad
,等,如果您愿意)。其次,此任务...
...没有产生列表;它返回一个数字。因此,在随后的任务中,当您编写时:
您正在尝试循环浏览
10
之类的内容。最后,
lineInfile
模块没有src
参数。如果您的目标是将
n
随机名称写入文件,则可能需要>过滤器,将一个随机列表随机:
There are multiple problems here. First, this isn't a list:
That's just a string. If you want a list, write:
Or:
(I've dropped the quotes, because they're not necessary, but you can write
'chad'
instead ofchad
, etc, if you prefer).Second, this task...
...does not produce a list; it returns a single number. So in the subsequent task, when you write:
You're trying to loop over something like the value
10
.Lastly, the
lineinfile
module doesn't have asrc
parameter.If your goal is to write
N
random names to a file, you might wantthe
shuffle
filter, which randomizes a list:Ansible-从列表中选择多个随机名称