当我遇到此例外时,问题与前卫有关。
就我而言,我能够修复它,包括项目的proguard-rules.pro文件中的以下规则。
# Preserve all public classes, and their public fields and
# methods.
-keep public class * {
public *;
}
希望这有帮助!
用print()函数替换返回
def shout(phrase):
if phrase == phrase.upper():
print("YOU'RE TOO LOUD")
else:
print("Can you speak up, I can barely hear you")
shout("I'M INTERESTED IN SHOUTING")
要更新WooCommerce中的现有订单,您将订单ID添加到URL中,例如此/wp-json/wc/v3/orders/< id>
,并且请求必须是 pot
。
要存储跟踪URL,我建议您将其保存为订单中的元_field。然后,您可以在WooCommerce中轻松访问它,并将其显示在所需的位置。请求看起来像这样:
{
"meta_data": [
{
"key": "_tracking_number",
"value": "XXXXXXXXXXXXX"
}
]
}
您可以在此处阅读更多有关它的信息 https://woocommerce.github.io/woocommerce-rest-api-docs/#update-an-cord
您为什么不只是在写语句中写下您所在的子例程的名称?
您无法(动态)(动态)给出或更改子例程的名称,因此,我认为没有理由尝试以这种方式访问它(关于该:虽然我不确定是不可能的以某种方式访问它,我敢肯定,这是错误的方法...您将使自己更麻烦,而不仅仅是硬编码)。
顺便说一句,你为什么要打印出来?一句话良好的诊断信息不会更有用吗?
除了设计决策,您可以通过在 kernal.php
文件中覆盖名称空间来实现这一目标:
<?php
declare(strict_types=1);
namespace App {
// Must use bracket notation in order to use global namespace in the same file
// See https://www.php.net/manual/en/language.namespaces.definitionmultiple.php#example-295
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
}
}
namespace {
// Begin the global namespace
if(!function_exists('_logger')) {
// Added my logger() function here works but must be called as
\App\_logger()
}
}
注意:此代码未经测试。
来源:
Edit 7 July:
From your comments I understand you were looking for something different, the assumption I made about why your function was giving multiple values was wrong. Hence this new answer from scratch:
The custom function you've written doesn't lend itself to row-by-row application, because it already processes all rows at once:
Given the following input:
congress <- c(104, 111, 104, 111, 104, 111)
latitude <- c(37.32935, 37.32935, 41.1134016, 41.1134016, 42.1554948, 42.1554948)
longitude <- c(-122.00954, -122.00954, 73.720356, 73.720356, -87.868850502543, -87.868850502543)
point_geo_test
contains these values:
> point_geo_test
[...]
congress geometry
1 104 POINT (-122.0095 37.32935)
2 111 POINT (-122.0095 37.32935)
3 104 POINT (73.72036 41.1134)
4 111 POINT (73.72036 41.1134)
5 104 POINT (-87.86885 42.15549)
6 111 POINT (-87.86885 42.15549)
and extract_district()
returns this:
> extract_district(point_geo_test, 104)
[...]
[1] "California-14" "California-14" "NA-NA" "NA-NA" "Illinois-10" "Illinois-10"
This is already a result for each row.唯一的问题是,虽然它们是每行的坐标的正确结果,但它们仅在国会104期间仅用于这些坐标的 name 。因此,这些值仅是有效的for the rows in point_geo_test
where congress == 104.
Extracting correct values for all rows
We will create a function that returns the correct data for all rows, eg the correct name for the在相关国会期间进行坐标。
我已经稍微简化了您的代码: df_test
不再是中间数据框架,而是直接定义在 point_geo_test
的创建中。我提取的任何值,我也将保存到此数据框架中。
library(tidyverse)
library(sf)
sf_use_s2(FALSE)
districts_104 <- st_read("districts104.shp")
districts_111 <- st_read("districts111.shp")
congress <- c(104, 111, 104, 111, 104, 111)
latitude <- c(37.32935, 37.32935, 41.1134016, 41.1134016, 42.1554948, 42.1554948)
longitude <- c(-122.00954, -122.00954, 73.720356, 73.720356, -87.868850502543, -87.868850502543)
point_geo_test <- st_as_sf(data.frame(congress, latitude, longitude),
coords = c(x = "longitude", y = "latitude"),
crs = st_crs(districts_104))
To keep the code more flexible and organized, I'll create a generic function that can fetch any parameter for the given coordinates:
extract_values <- function(points, parameter) {
# initialize return values, one for each row in `points`
values <- rep(NA, nrow(points))
# for each congress present in `points`, lookup parameter and store in the rows with matching congress
for(cong in unique(points$congress)) {
shapefile <- get(paste0("districts_", cong))
st_join_results <- st_join(points, shapefile, join = st_within)
values[points$congress == cong] <- st_join_results[[parameter]][points$congress == cong]
}
return(values)
}
Examples:
> extract_values(point_geo_test, 'STATENAME')
[1] "California" "California" NA NA "Illinois" "Illinois"
> extract_values(point_geo_test, 'DISTRICT')
[1] "14" "15" NA NA "10" "10"
Storing values
point_geo_test$state <- extract_values(point_geo_test, 'STATENAME')
point_geo_test$district <- extract_values(point_geo_test, 'DISTRICT')
point_geo_test$name <- paste(point_geo_test$state, point_geo_test$district, sep = "-")
Result:
> point_geo_test
Simple feature collection with 6 features and 4 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: -122.0095 ymin: 37.32935 xmax: 73.72036 ymax: 42.15549
Geodetic CRS: GRS 1980(IUGG, 1980)
congress state district name geometry
1 104 California 14 California-14 POINT (-122.0095 37.32935)
2 111 California 15 California-15 POINT (-122.0095 37.32935)
3 104 <NA> <NA> NA-NA POINT (73.72036 41.1134)
4 111 <NA> <NA> NA-NA POINT (73.72036 41.1134)
5 104 Illinois 10 Illinois-10 POINT (-87.86885 42.15549)
6 111 Illinois 10 Illinois-10 POINT (-87.86885 42.15549)
截至2020年8月: 现代浏览器对 =“ https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/string/replaceall/replaceall” rel =“ noreferrer”>
string.replaceall(replaceall(Replaceall() /a>由ecmascript 2021语言规范定义。
对于较旧/旧的浏览器:
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\amp;'); // amp; means the whole matched string
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
这是如何演变的:
str = str.replace(/abc/g, '');
回答评论“如果'abc'作为变量是什么
var find = 'abc';
var re = new RegExp(find, 'g');
str = str.replace(re, '');
? stackoverflow.com/users/49153/click-upvote"> click upvote 的评论,您可以更简化它:
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
注意:正则表达式包含特殊(meta)字符,以及AS在中盲目地通过一个参数在上面找到
函数而无需预处理以逃脱这些字符是危险的。 mozilla开发人员网络's javaScript指南正式表达式指南,它们呈现以下实用程序功能(至少已更改了至少已更改由于此答案最初是两次,因此请确保检查MDN站点是否有潜在的更新):
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\amp;'); // amp; means the whole matched string
}
因此,为了使 felpaceAll()
函数上述更安全,可以将其修改为以下内容。还包括 Escaperegexp
:
function replaceAll(str, find, replace) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
文档中正在解释的是,您可以通过对“ MuiloAdingButton-root”类造型来对根组件(LoadingButton Container Div)进行样式。
基本上,您需要具有针对此类的CSS样式,并将其称为组件中:
.MuiLoadingButton-root {
background-color: #FFF;
}
看完我的特使日志后,我意识到路径被称为标题“:路径”。
pass_through_matcher
数学标题。
然后只添加:
pass_through_matcher:
- name: ":path"
prefix_match: "/healthz"
- name: ":path"
prefix_match: "/api/v1/myResource1"
在没有LUA过滤器的情况下,在我的conf中(请参阅我以前的答案)。
您可以尝试覆盖模型的保存功能:
class Model(models.Model):
doucment_image = models.ImageField(upload_to='sellerinfo', null=True, blank=True)
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
# Call scaled_image if doucment_image is provided
if self.doucment_image:
self.doucment_image = scaled_image(self.doucment_image.path, self.doucment_image.path)
您无权访问 /上传 /在此服务器上。
尝试以下内容:
sudo chmod -R 777 /uploads
时,请替换并尝试此操作
您可以在注释 @when(“^user Enters(。+)和(。+)$” 。
干得好,
const a = [1, 2, 3]
const b = [1, 2, 3, 4, 5]
const diff = b.filter(e => !a.includes(e))
console.log(diff)
上述大多数答案都不适用于无序列表。
这也适用于无序列表。
const a = [3, 2, 1]
const b = [1, 2, 3, 4, 5]
const diff = b.filter(e => !a.includes(e))
console.log(diff)
如果A的大小大于B
const a = [1, 2, 3, 4, 5]
const b = [3, 2, 1]
const diff = a.length > b.length ? a.filter(e => !b.includes(e)) : b.filter(e => !a.includes(e))
console.log(diff)
如果有一个
date
datatype列(应该为;我们称其为datum
),则可以例如,如果将日期存储为字符串(中
varchar2 列),然后首先使用
to_date
函数使用适当的格式模型将其转换为有效date
datatype值。例如,如果将值存储为20220715(这是
yyyymmdd
),则其余查询是相同的:
当心! Oracle不将字符串作为日期处理!该列中可能有无效的值,例如“ 20AC#713”;将
to_date
应用于它会引起错误(因为这显然不是日期)。或者,如果有“ 20220230”(2月30日),您将再次出现错误。始终将日期存储到
date
数据类型列!If there's a
DATE
datatype column (should be; let's call itdatum
), then you could e.g.If you stored dates as strings (into a
VARCHAR2
column), then first convert it to a validdate
datatype value using theTO_DATE
function with appropriate format model.For example, if values are stored as 20220715 (which is
yyyymmdd
),The rest of query is just the same:
Beware! Oracle doesn't handle strings as dates! There might be invalid values in that column, e.g. "20ac#713"; applying
to_date
to it will raise error (as that's obviously not a date). Or, if there were "20220230" (30th of February), you'll get error again.Always store dates into
date
datatype columns!在过去4年的一月到三月之间获取数据