您的输入具有不同的id
属性,但它们都具有相同的name
。正是name
确定提交的内容,因为您已经在编写此行时就已经发现了未意识到的那样:
<?php if (isset($_POST['switch_sticker'])){echo 'checked="checked"';}?>
如果
语句中没有任何内容,则围绕循环有所不同;它每次都查看相同的值$ _ post ['switch_sticker']
。
同时,JavaScript代码本质上与问题无关,因为它仅更改各种元素的value
。这些将显示为$ _ post ['switch_sticker']
变量的值,但是由于只有一个变量和大量值,因此最终将出现列表中的最后一个。
解决方案是给您每个复选框自己的name
,就像您给他们自己的value
:name =“ switch_sticker_&lt;?= $ key?gt; “
。然后在php中查找该名称:&lt;?php if(ISSET($ _ post ['switch_sticker_'。$ key]。 。
您还可以在form 中使用名称
某物[sosity_else]
,例如name =“ switch_sticker [&lt;?= $键?&gt;] ?这会导致PHP提交时创建 array ,这要好得多 - 您可以写
foreach($ _post ['switch_sticker'] as $ nistkitykey,它可以编写
诸如
=&gt; $提交值){...}
。
这就是为什么我们不应该将DART中的地图用作数据结构的原因之一,因为它使表达元素彼此相等的含义相当复杂。
因此,我建议通过创建user
类这样的类来解决此问题:
class User {
String name;
String user_id;
User({required this.name, required this.user_id});
@override
int get hashCode => user_id.hashCode;
@override
bool operator ==(Object other) => other is User && user_id == other.user_id;
@override
String toString() => '{Name: $name, User ID: $user_id}';
}
class User {
String name;
String user_id;
User({required this.name, required this.user_id});
@override
int get hashCode => Object.hash(name, user_id);
@override
bool operator ==(Object other) =>
other is User && name == other.name && user_id == other.user_id;
@override
String toString() => '{Name: $name, User ID: $user_id}';
}
通过这样做,我们可以做:
void main() {
List<User> userList = [
User(name: 'john', user_id: '251'),
User(name: 'will', user_id: '255'),
User(name: 'jack', user_id: '251'),
];
userList.forEach(print);
// {Name: john, User ID: 251}
// {Name: will, User ID: 255}
// {Name: jack, User ID: 251}
}
然后我们可以执行toset()
这样的技巧:
void main() {
List<User> userList = [
User(name: 'john', user_id: '251'),
User(name: 'will', user_id: '255'),
User(name: 'jack', user_id: '251'),
];
List<User> uniqueUserList = userList.toSet().toList();
uniqueUserList.forEach(print);
// {Name: john, User ID: 251}
// {Name: will, User ID: 255}
}
我注意到您的示例是制作的,因此您仅查看user_id
以确定是否具有重复元素。 不知道您的示例是否只是错误
class User {
String name;
String user_id;
User({required this.name, required this.user_id});
@override
int get hashCode => Object.hash(name, user_id);
@override
bool operator ==(Object other) =>
other is User && name == other.name && user_id == other.user_id;
@override
String toString() => '{Name: $name, User ID: $user_id}';
}
我 定义对其进行的定义:
void main() {
List<Map<String, String>> userList = [
{'name': 'john', 'user_id': '251'},
{'name': 'will', 'user_id': '255'},
{'name': 'jack', 'user_id': '251'} // duplicate
];
final set = LinkedHashSet<Map<String, String>>(
equals: (map1, map2) {
final id1 = map1['user_id'];
final id2 = map2['user_id'];
return id1 != null && id2 != null && id1 == id2;
},
hashCode: (map) => map['user_id'].hashCode,
);
set.addAll(userList);
List<Map<String, String>> uniqueUserList = set.toList();
uniqueUserList.forEach(print);
// {name: john, user_id: 251}
// {name: will, user_id: 255}
}
使用MAP
对象解决此问题,您可以使用以下以下在其中创建set
的 这总是有点丑陋,因为MAP
不适用于以前所述的数据结构。
更新:
以下是做您问题提出的方法:
import pandas as pd
data = pd.DataFrame([pd.Series([k for k in range(10)]) for j in range(5)] for i in range(8))
ni, nj = data.shape
nk = len(data.loc[0, 0])
print(ni, nj, nk)
data2 = data.applymap(lambda x: x[:len(x) // 2])
print(*data2.shape, len(data2.loc[0, 0]))
输出:
8 5 10
8 5 5
如果您的数据位于3D Numpy数组中,则实际上可以切成3D数组。
这是一个往返pandas-to-numpy to-pandas解决方案:
import pandas as pd
import numpy as np
data = pd.DataFrame([pd.Series([k for k in range(10)]) for j in range(5)] for i in range(8))
ni, nj = data.shape
nk = len(data.loc[0, 0])
print(ni, nj, nk)
xf = [y.to_numpy() for y in data.to_numpy().flatten()]
n = np.array(xf).reshape([ni, nj, nk])
print(n.shape)
print(n)
n2 = n[:, :, :nk // 2]
print(n2.shape)
print(n2)
data2 = pd.DataFrame([pd.Series(n2[i, j, :]) for j in range(n2.shape[1])] for i in range(n2.shape[0]))
ni, nj = data2.shape
nk = len(data2.loc[0, 0])
print(ni, nj, nk)
这是从包含k-Length系列值的IXJ dataframe转换为3D numpy阵列n
的输入:
[[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]
[[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]
[0 1 2 3 4 5 6 7 8 9]]]
这是3D Numpy Array N2
具有原始3D阵列(NK // 2)的一半的k- extent:
[[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]
[[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]
[0 1 2 3 4]]]
作为最后一步,切成3D Numpy Array n2
是转换回包含长度NK // 2的串联值的IXJ数据框。
我在github中找到了这个问题:
https://github.com/azure/azure/azure-storage-scopopy/assues/sissus/ 903
如GitHub链接中所述,我能够通过在ENV变量下设置AZCOPY工作。
mkdir /opt/myapp/azlogs
export AZCOPY_LOG_LOCATION=/opt/myapp/azlogs
这基本上是AZCOPY的日志位置。我正在考虑使此ENV变量的一部分成为图像的一部分,而不必每次将其输入。
编辑1:
我遇到了另一个错误。
panic: mkdir plans: permission denied
看来Azcopy想要在当前工作DIR上创建计划目录。因此,请确保您正在运行AZCOPY的用户以及在当前工作DIR上创建新文件夹的权限。
您可以应用内置str.Str.Strip
,str.rstrip
(右侧带)和str.l.lstrip
(左侧)的矢量化版本)使用pandas.series.str
:
pd。 Series.str.Strip
矢量化字符串条pd.series.str.rstrip
矢量化的右侧条
:
s.str.lstrip('[').str.rstrip(']')
您必须在插入图像之前导入该图像是否来自目录而不是链接。
这样:
import logo from './logo.png'
然后您像这样插入它:
<img src={logo} alt="Logo" />
我不能错过这个机会插入乔什·布洛克(Josh Bloch)的书有效的java 版)。第10章是Java序列化的不可或缺的资源。
根据Josh,自动生成的UID是基于类名称,实现的接口以及所有公共和受保护的成员生成的。以任何方式更改这些中的任何一个都会更改serialversionuid
。因此,您不需要仅当您确定不超过一个版本的班级将被序列化(跨进程或以后从存储中检索)时,就不需要与他们混乱。
如果您暂时忽略它们,并以后发现您需要以某种方式更改类,但请维持类的兼容性,则可以使用JDK工具 serialver 来生成serialversionuid
在 old 类上,并在新类中明确设置该>。 (根据您的更改,您可能需要还需要通过添加writeObject
和readObject
方法来实现自定义序列化 - 请参见serializable
javadoc或上述第10章。
我认为下面答案来自雷诺·塔内克(Renaud Tarnec)肯定会为您提供帮助。
如果您查看“调整图像”扩展程序的A>,您会看到构成构成扩展的云函数是由a onfinalize 事件,这意味着:
当新对象(或现有对象的新一代)是
成功创建的存储桶。这包括复制或重写
现有对象。
因此,如果不重写/再生现有图像,则不会触发扩展名。
但是,您可以轻松地编写自己的云功能,该功能可以执行相同的操作,但可以通过调用特定URL触发( https云功能)或通过在临时firestore集合中创建新文档(背景触发cf )。
该云功能将执行以下步骤:
- 获取存储桶的所有文件,请参阅 getfiles> ()
Google Cloud Storage Node.js客户端API。此方法返回
getfilesresponse object object 是文件实例的阵列。 - 通过在数组上循环,对于每个文件,请检查文件是否具有
在存储桶中相应的调整大小图像(取决于您的方式
配置了扩展名,调整大小的图像可能是特定的
文件夹) - 如果文件没有相应的调整大小映像,请执行
该文件的扩展云功能的相同业务逻辑。
有一个官方的云功能 sample 显示如何创建如何创建云存储触发的firebase函数将创建从上传的映像创建调整大小的缩略图并将其上传到数据库URL(请参阅index.js file的最后一行)
注意:如果您有很多可以处理的文件,则可能很可能有效通过批处理,由于云功能执行的限制为9分钟。另外,根据要处理的图像数量,您可能需要增加超时值和/或云功能分配的内存,请参见 https://firebase.google.com/docs/functions/manage-functions/manage-functions#sety_time_time_time_and_and_memory_allocation
const data= [
"the lions of teranga",
"tiger woods",
"The Truman Show",
"Shutter Island",
"The Gold Rush",
]
inputData = "lions"
let a = data.filter(e => {
str = e.toLowerCase()
if (str.match(inputData.toLowerCase())){
return e
}
})
console.log(a)
此处过滤器返回返回的对象。在这里,您可以通过任何单词或字符搜索并作为数组返回。
不,请参见; min_samples_split
不考虑样本权重。与min_samples_leaf
及其加权cousin min_weight_fraction_leaf
( source )。
您的示例建议一个简单的实验检查:
from sklearn.tree import DecisionTreeClassifier
import numpy as np
X = np.array([1, 2, 3]).reshape(-1, 1)
y = [0, 0, 1]
tree = DecisionTreeClassifier()
tree.fit(X, y)
print(len(tree.tree_.feature)) # number of nodes
# 3
tree.set_params(min_samples_split=10)
tree.fit(X, y)
print(len(tree.tree_.feature))
# 1
tree.set_params(min_samples_split=10)
tree.fit(X, y, sample_weight=[20, 20, 20])
print(len(tree.tree_.feature))
# 1; the sample weights don't count to make
# each sample "large" enough for min_samples_split
我一直在看您的代码片段。您的正确选项不会扩展。看起来可能是这样,因为您当前的HTML/CSS正在扩展父容器。如果您需要2列,则需要在HTML/CSS中这样做:
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.tailwindcss.com"></script>
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
<style>
.md-w-48\/100 {
width: 48%;
}
</style>
</head>
<body>
<div class="flex flex-row flex-wrap w-full">
<div class="flex flex-row flex-wrap w-full mt-8 px-6 xl:px-0">
<h2 class="text-4xl font-mont font-bold md:text-left text-center">Casino & Gambling FAQs</h2>
</div>
<div class="max-w-7xl mt-8 px-6 xl:px-0 w-1/2 inline-block">
<div class="flex flex-col flex-wrap justify-between w-full">
<div class="flex flex-wrap flex-row justify-between mt-8 w-full">
<div x-init="" x-data="{expanded: false}" :class="expanded ? 'h-full' : 'h-12'" class="w-full flex flex-wrap flex-col h-12">
<div @click="expanded = !expanded" class="flex items-center px-10 py-4 border-b bg-white rounded-lg cursor-pointer">
<div class="font-bold font-lato text-xsm bg-white">question</div>
<div class="ml-auto p-2">
<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.77083 0.937549C7.68535 0.850049 7.57545 0.812549 7.46555 0.812549C7.35565 0.812549 7.23354 0.862549 7.16027 0.937549L4.03424 4.11255L0.932622 0.937549C0.847145 0.850049 0.725034 0.800049 0.615134 0.800049C0.505234 0.800049 0.383123 0.850049 0.309857 0.925049C0.138902 1.10005 0.138902 1.38755 0.309857 1.56255L3.71675 5.06255C3.8877 5.23755 4.16856 5.23755 4.33951 5.06255L7.75862 1.57505C7.94178 1.40005 7.94178 1.11255 7.77083 0.937549Z" fill="#080F33">
</path>
</svg>
</div>
</div>
<div x-show="expanded" class="px-10 py-4 text-left font-lato bg-gray-50 text-gray-500 flex-1" style="display: none;">
'just a bunch of text'
</div>
</div>
</div>
<div class="flex flex-wrap flex-row justify-between mt-8 w-full">
<div x-init="" x-data="{expanded: false}" :class="expanded ? 'h-full' : 'h-12'" class="w-full flex flex-wrap flex-col h-12">
<div @click="expanded = !expanded" class="flex items-center px-10 py-4 border-b bg-white rounded-lg cursor-pointer">
<div class="font-bold font-lato text-xsm bg-white">question</div>
<div class="ml-auto p-2">
<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.77083 0.937549C7.68535 0.850049 7.57545 0.812549 7.46555 0.812549C7.35565 0.812549 7.23354 0.862549 7.16027 0.937549L4.03424 4.11255L0.932622 0.937549C0.847145 0.850049 0.725034 0.800049 0.615134 0.800049C0.505234 0.800049 0.383123 0.850049 0.309857 0.925049C0.138902 1.10005 0.138902 1.38755 0.309857 1.56255L3.71675 5.06255C3.8877 5.23755 4.16856 5.23755 4.33951 5.06255L7.75862 1.57505C7.94178 1.40005 7.94178 1.11255 7.77083 0.937549Z" fill="#080F33">
</path>
</svg>
</div>
</div>
<div x-show="expanded" class="px-10 py-4 text-left font-lato bg-gray-50 text-gray-500 flex-1" style="display: none;">
'just a bunch of text'
</div>
</div>
</div>
</div>
</div>
<div class="max-w-7xl mt-8 px-6 xl:px-0 w-1/2 inline-block">
<div class="flex flex-col flex-wrap justify-between w-full">
<div class="flex flex-wrap flex-row justify-between mt-8 w-full">
<div x-init="" x-data="{expanded: false}" :class="expanded ? 'h-full' : 'h-12'" class="w-full flex flex-wrap flex-col h-12">
<div @click="expanded = !expanded" class="flex items-center px-10 py-4 border-b bg-white rounded-lg cursor-pointer">
<div class="font-bold font-lato text-xsm bg-white">question</div>
<div class="ml-auto p-2">
<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.77083 0.937549C7.68535 0.850049 7.57545 0.812549 7.46555 0.812549C7.35565 0.812549 7.23354 0.862549 7.16027 0.937549L4.03424 4.11255L0.932622 0.937549C0.847145 0.850049 0.725034 0.800049 0.615134 0.800049C0.505234 0.800049 0.383123 0.850049 0.309857 0.925049C0.138902 1.10005 0.138902 1.38755 0.309857 1.56255L3.71675 5.06255C3.8877 5.23755 4.16856 5.23755 4.33951 5.06255L7.75862 1.57505C7.94178 1.40005 7.94178 1.11255 7.77083 0.937549Z" fill="#080F33">
</path>
</svg>
</div>
</div>
<div x-show="expanded" class="px-10 py-4 text-left font-lato bg-gray-50 text-gray-500 flex-1" style="display: none;">
'just a bunch of text'
</div>
</div>
</div>
<div class="flex flex-wrap flex-row justify-between mt-8 w-full">
<div x-init="" x-data="{expanded: false}" :class="expanded ? 'h-full' : 'h-12'" class="w-full flex flex-wrap flex-col h-12">
<div @click="expanded = !expanded" class="flex items-center px-10 py-4 border-b bg-white rounded-lg cursor-pointer">
<div class="font-bold font-lato text-xsm bg-white">question</div>
<div class="ml-auto p-2">
<svg width="8" height="6" viewBox="0 0 8 6" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M7.77083 0.937549C7.68535 0.850049 7.57545 0.812549 7.46555 0.812549C7.35565 0.812549 7.23354 0.862549 7.16027 0.937549L4.03424 4.11255L0.932622 0.937549C0.847145 0.850049 0.725034 0.800049 0.615134 0.800049C0.505234 0.800049 0.383123 0.850049 0.309857 0.925049C0.138902 1.10005 0.138902 1.38755 0.309857 1.56255L3.71675 5.06255C3.8877 5.23755 4.16856 5.23755 4.33951 5.06255L7.75862 1.57505C7.94178 1.40005 7.94178 1.11255 7.77083 0.937549Z" fill="#080F33">
</path>
</svg>
</div>
</div>
<div x-show="expanded" class="px-10 py-4 text-left font-lato bg-gray-50 text-gray-500 flex-1" style="display: none;">
'just a bunch of text'
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
如您所见,我已经将您的列分为2个不同的inline-block
元素。这样,就不被视为一个父母,而扩大孩子不会在另一侧扩展容器。
添加onclick = {(e)=&gt; e.stoppropagation()}
in &lt; form.check&gt; ...&lt;/form.check>
。e.stoppropagation()
在标签中将有助于此标签阻止父母的onClick事件。
这里的代码: htttps:// codesandbox。 io/s/s/platvown-with-checkbox-forked-88H9m6?file =/src/app.js
import "./styles.scss";
import "bootstrap/dist/css/bootstrap.min.css";
import { Dropdown, Form } from "react-bootstrap";
export default function App() {
return (
<div className="App">
<Dropdown className="dropdown-groove">
<Dropdown.Toggle variant="outline-secondary " id="dropdown-basic">
Select...
<label className="dropdown-label">Dropdown label</label>
</Dropdown.Toggle>
<Dropdown.Menu>
<Dropdown.Item href="#/action-1">
{" "}
<Form.Check
onClick={(e) => e.stopPropagation()} //<=== Add here
className="checkbox-groove"
inline
label="Unselected"
name="group1"
type="checkbox"
/>{" "}
</Dropdown.Item>
<Dropdown.Item href="#/action-2">List Item 2</Dropdown.Item>
<Dropdown.Item href="#/action-3">List Item 3</Dropdown.Item>
<Dropdown.Item href="#/action-4">List Item 4</Dropdown.Item>
<Dropdown.Item href="#/action-5">List Item 5</Dropdown.Item>
</Dropdown.Menu>
</Dropdown>
</div>
);
}
import 'dart:convert';
const raw =
'''
[{"color":"#000000","quantity":"100","price":"999","attribute":{"id":1,"name":"Iphone 12"}},{"color":"#cd7d96","quantity":"40","price":"555","attribute":{"id":2,"name":"SAMSUNG"}},{"color":"#66cccc","quantity":"500","price":"1000","attribute":{"id":1,"name":"OPPO"}}]
''';
typedef JMap = Map<String, dynamic>;
typedef LJMap = List<JMap>;
void groupById() {
final data = (jsonDecode(raw) as List).cast<JMap>();
var result = <JMap>[];
data.map<int>((m) => m['attribute']['id']).toSet().forEach((e) {
result.add({
'attribute_id': e,
'values': data.where((m) => m['attribute']['id'] == e).map((m) => m['color']).toList(),
});
});
print(result);
}
void main(List<String> args) {
groupById();
}
输出:
[{attribute_id: 1, values: [#000000, #66cccc]}, {attribute_id: 2, values: [#cd7d96]}]
使用您的Dropbox数据:
library(terra)
ndwi <- rast('Clip_ndwi_poslije1.tif')
ndwi_vec <- values(ndwi, mat = FALSE)
> length(which(ndwi_vec > 0))
[1] 21157
> length(which(ndwi_vec <= 0))
[1] 13217
> dim(ndwi)[1]
[1] 220
> dim(ndwi)[1]*dim(ndwi)[2]
[1] 58300
> sum(length(which(ndwi_vec > 0)), length(which(ndwi_vec <= 0)))
[1] 34374
> table(is.na(ndwi[])) # see below
FALSE TRUE
34374 23926
表方法来自 sof-gis?s ,让您开始。
基于您的答案,我将代码抽象为指令,因此更清晰,因此无需处理事件:
只需使用它 :在您的输入元素中:
Based on your answer, I abstracted the code into a directive so it's clearer and there's no need to handle events:
Just use it in your input element:
专注于Angular以后的输入(模态显示)之后,在Safari iOS中显示键盘