这里的诀窍是要了解 pandas
对象非常关心 .index
很多。由于 .index
, series
可以支持几乎是类似行为。从这个角度来看,就像在字典上检查在中检查键是否存在,也有意义地说, in in pandas
object in in in索引存在。
因此,使用上述内容,我们可以检查:
>>> import pandas as pd
>>> s = pd.Series([1,2,3,4,6,7,8,9])
>>> s.index
RangeIndex(start=0, stop=8, step=1)
>>> 5 in s # implicitly check if 5 is in s.index
True
>>> 5 in s.index # explicitly check if 5 is in s.index
True
>>> 5 in s.values # explicitly check if 5 is in values
False
一种替代方法来检查值是否在 series
中您可以使用一些布尔逻辑:
>>> (5 == s).any()
False
另请参阅也是这个答案。
假设您控制网页的源代码,则有两种将数据传递到HTML网页中的方法。请注意,<%= coords%>
是ASP.NET的事物,可将信息从加载后的前端传递到前端,并且需要更多的工作才能工作(更容易工作选项)。
方法1
如果您只需要一种方式通信(传递到网页,但不需要将任何内容发送回WPF C#),则可以将信息作为查询字符串传递,然后解析当您的应用程序加载时。这真的很容易。这是一个网页的示例,该网页使用可选的 Center
和 Zoom
参数显示为this test.html?center = 51.50632,-0.12714 & Zoom = 15
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="utf-8" />
<meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
</head>
<body>
<div id='myMap' style='width: 100vw; height: 100vh;'></div>
<script>
var map;
function GetMap(){
//Default center/zoom values.
let center = new Microsoft.Maps.Location(0, 0);
let zoom = 1;
//Get the queryStringuery string of the URL.
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
//Extract center infromation from query string.
if (urlParams.has('center')) {
//Parse coordinates from the center parameter. Assume that string is in the format "latitude, longitude". Comma/space optional, must have atleast one.
let parts = urlParams.get('center').split(/[,\s]+/gi);
if(parts.length >= 2){
let lat = parseFloat(parts[0]);
let lon = parseFloat(parts[1]);
if(!isNaN(lat) && !isNaN(lat)){
center = new Microsoft.Maps.Location(lat, lon);
}
}
}
if (urlParams.has('zoom')) {
let z = parseInt(urlParams.get('zoom'));
if(!isNaN(z)){
zoom = z;
}
}
map = new Microsoft.Maps.Map('#myMap', {
center: center,
zoom: zoom
});
}
</script>
<script type='text/javascript' src='https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=[Your Bing Maps Key]' async defer></script>
</body>
</html>
这种方法的主要限制是:
- 您只能传递最大URL长度允许的信息(2083个字符)。
- 页面加载时仅发送一次信息。如果要发送新信息,则必须重新加载该页面(效率低下,并且在使用Bing Maps时可以生成其他地图会话)。
- 无法将信息发送回WPF应用程序。
方法2
如果要进行双向通信,或者想避免方法1的局限性,则可以在应用程序中包装Web浏览器控件并利用互操作性。当前WPF提供WebView2,它允许您将边缘浏览器嵌入应用程序 https://learn.microsoft.com/en-us/microsoft-ge/webview2/get-started/wpf 这是一篇很棒的详细博客文章,介绍了如何做到这一点: https://weblog.west-wind.com/posts/2021/jan/26/chromium-webview2-control-webview2-control-and-net-net-net-net-to-javascript-interop-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-part-2
另外,您可以可以还使用Chromium/CEFSHARP( https://cefsharp.github.io/ ),而不是WPF的WebView2 Control(它可能会使您的应用程序更大,因为它不会利用已经安装在已经安装在该浏览器上的浏览器系统: https://dev.to/noseratio/comparing-process-working-sets-of-webview基于windows-desktop-apps-5dkk )。
更新:方法3
您可以将HTML文件读取为字符串,然后在占位符上进行查找和替换。在下面的示例中,我使HTML文件成为嵌入式资源(如果您想在某个时候将其运送到其他人,则可能需要做的事情)。我称其为 mappage.html
,并将其放在项目的根目录中。将HTML文件添加到您的项目中,转到属性并将构建操作设置为嵌入式资源。要读取它,您需要将项目的名称空间包括在文件名路径中,在我的情况下,名称空间为 simplewebbrowser
,因此,当读取为 simple> simple> simple weebbrowser.mappage时,文件名将是
。 html 。然后,在您的C#代码中,您可以使用这样的方法:
private void LoadMap(double latitude, double longitude)
{
Assembly assembly = Assembly.GetExecutingAssembly();
using (var reader = new StreamReader(assembly.GetManifestResourceStream("SimpleWebBrowser.mapPage.html")))
{
var html = reader.ReadToEnd();
html = html.Replace("<%=coords%>", latitude + " " + longitude);
myBrowser.NavigateToString(html);
}
}
您的HTML代码将处理这样的输入:
<script type='text/javascript'>
var map;
var coords = '<%=coords%>';
function GetMap() {
//Default center.
var center = new Microsoft.Maps.Location(55, 0);
//Parse the coords string and get lat/lon values.
var parts = coords.split(' ');
if(parts.length >= 2){
let lat = parseFloat(parts[0]);
let lon = parseFloat(parts[1]);
if(!isNaN(lat) && !isNaN(lat)){
center = new Microsoft.Maps.Location(lat, lon);
}
}
map = new Microsoft.Maps.Map('#myMap', {center: });
...
我无法复制您的错误。一方面,您的0.10845值不正确:请记住,它可以以这种方式计算(即 logistic(z)
在您的实现中。但是,无论如何,我计算的价值与Pytorch产生的价值一致。
这是逻辑函数:
import numpy as np
def logistic(z, derivative=False):
if not derivative:
return 1 / (1 + np.exp(-z))
else:
return logistic(z) * (1 - logistic(z))
logistic(0.8762, derivative=True)
这将产生 0.20754992931590668
。
现在使用pytorch:
import torch
t = torch.Tensor([0.8762])
t.requires_grad = True
torch.sigmoid(t).backward()
t.grad
这会产生张量([0.2075])
。
您可以使用:
kubectl get hpa -A -w
使用 -A
选项,它可以从所有 namespaces
中为您提供所有HPA,如果您要指定 namepace
,您可以使用 -n
选项。并且 -w
参数用于手表,因此您有一个刷新的接口,可在HPA ressources上为您提供信息。
这本质上是一个错误,已在Linux 5.15.78中固定。
日志所说的:
With just the forward declaration of the 'struct pt_regs' in
syscall_wrapper.h, the syscall stub functions:
__[x64|ia32]_sys_*(struct pt_regs *regs)
will have different definition of 'regs' argument in BTF data
based on which object file they are defined in.
If the syscall's object includes 'struct pt_regs' definition,
the BTF argument data will point to a 'struct pt_regs' record,
like:
[226] STRUCT 'pt_regs' size=168 vlen=21
'r15' type_id=1 bits_offset=0
'r14' type_id=1 bits_offset=64
'r13' type_id=1 bits_offset=128
...
If not, it will point to a fwd declaration record:
[15439] FWD 'pt_regs' fwd_kind=struct
and make bpf tracing program hooking on those functions unable
to access fields from 'struct pt_regs'.
Include asm/ptrace.h directly in syscall_wrapper.h to make sure all
syscalls see 'struct pt_regs' definition. This then results in BTF for
'__*_sys_*(struct pt_regs *regs)' functions to point to the actual
struct, not just the forward declaration.
这是提交 在 asm/ptrace.h 带有实际定义
#include&lt; asm/ptrace.h&gt;
解决了问题。
getRangeByName()
不是表格的方法,而是电子表格。因此,您应该尝试:
var bot_id = SpreadsheetApp.getActiveSpreadsheet().getRangeByName("bot_id");
我正在使用NextJS版本14和Next-auth 4.24,并与下一个Auth Middleware一起发现了同样的问题。我正在使用下一个Auth的数据库策略。对于仍然弄清楚这个问题的每个人。我这样管理的
import { withAuth } from "next-auth/middleware";
export default withAuth({
callbacks: {
authorized: ({ req }) => {
// verify token and return a boolean
const sessionToken = req.cookies.get("next-auth.session-token");
if (sessionToken) return true;
else return false;
},
},
});
export const config = { matcher: ["/home/:path*"] };
想法是检查令牌cookie是否仍然存在,如果不是,请重定向
不幸的是,简短的答案是,不可能通过来源生成器来达到您希望的精确解决方案。原因是源发电机的绝对设计理念之一(我感到沮丧,但可以理解理由)是通过使用源发电机来积极地禁止现有源文件突变。换句话说,您实际上无法修改任何手写类的代码。源生成器为。它仍然可以非常强大的原因是通过使用部分类(其定义在多个文件中声明的类型)。
有了这个序言,让我们更仔细地看一下您的确切用例。您有此方法:
public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
[ValidateParameter(typeof(EmailValidator))] Email email,
[ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
User user = new(name, email, dateOfBirth);
_userRepository.Add(user);
return user;
}
您想将其转换为此方法:
public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
[ValidateParameter(typeof(EmailValidator))] Email email,
[ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
Activator.CreateInstance<NameValidator>().Validate(name);
Activator.CreateInstance<EmailValidator>().Validate(email);
Activator.CreateInstance<AdultValidator>().Validate(dateOfBirth);
User user = new(name, email, dateOfBirth);
_userRepository.Add(user);
return user;
}
如您所见,您想要的结果需要修改您的 createuser
方法,这是不可能的。
一个可以使您一半的解决方案是为任何方法生成一种用 validateParameter
属性的参数生成自定义验证方法。例如,您可以生成此方法:
// Generated
private void ValidateCreateUser(Name name, Email email, DateOfBirth dateOfBirth)
{
Activator.CreateInstance<NameValidator>().Validate(name);
Activator.CreateInstance<EmailValidator>().Validate(email);
Activator.CreateInstance<AdultValidator>().Validate(dateOfBirth);
}
然后在您的 createuser
方法中,您可以直接自己调用此方法:
public User CreateUser( [ValidateParameter(typeof(NameValidator))] Name name,
[ValidateParameter(typeof(EmailValidator))] Email email,
[ValidateParameter(typeof(AdultValidator))] DateOfBirth dateOfBirth)
{
ValidateCreateUser(name, email, dateOfBirth); // You'd add this line yourself
User user = new(name, email, dateOfBirth);
_userRepository.Add(user);
return user;
}
这是否是一个足够成功的结果,只有您可以说。
如果您想准确地找到所希望的解决方案,恐怕您在评论中的怀疑是您必须求助于Fody是准确的。创建自定义FODY插件需要对Fody和C#IL有相当深的了解。
无耻的插头:我维护了一个名为 lyea 的fody库这将使您很容易通过 method interceptors> method Interpectors 。
在这种情况下,刚刚添加了一些CSS的技巧,添加了 burgeropen
此类为身体元素
body.burgerOpen {
overflow: hidden;
}
尝试以下演示
const burger = document.querySelector('#burger')
const tl = gsap.timeline()
tl.to('.menu-link', {
translateY: '100%',
duration: 0.5,
})
tl.to('.menu-overlay', {
width: '0'
})
burger.addEventListener('click', () => {
tl.reversed(!tl.reversed());
$('body').toggleClass('burgerOpen');
})
:root {
--zIndex-overlay: 900;
--zIndex-navbar: 905;
--colors-text: white;
--colors-background: black;
--colors-contast: #f4e285;
}
body {
color: var(--colors-text);
background-color: #304a36;
font-family: "Prompt", sans-serif;
font-variant-ligatures: common-ligatures;
}
*, *::before, *::after {
border-width: 0;
border-style: solid;
box-sizing: border-box;
word-wrap: break-word;
}
a {
background-color: transparent;
color: inherit;
-webkit-text-decoration: inherit;
text-decoration: inherit;
}
.menu-overlay {
position: fixed;
left: 0;
top: 0;
right: auto;
bottom: 0;
z-index: var(--zIndex-overlay);
width: 100%;
background-color: rgba(0, 0, 0, 0.7);
}
.menu-content {
width: 50%;
height: 100%;
overflow-x: hidden;
position: relative;
display: flex;
align-items: center;
transition-delay: 0.1s;
background-color: var(--colors-background);
}
.menu-list {
list-style: none;
width: 100%;
display: flex;
flex-direction: column;
padding-left: 10%;
}
.menu-list li {
width: fit-content;
overflow: hidden;
}
.menu-link {
font-size: 3.5rem;
display: inline-block;
transform: translateY(0);
}
.menu-link:hover {
color: white;
-webkit-text-fill-color: rgba(255, 255, 255, 0);
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: #fff;
}
.menu-footer {
position: absolute;
bottom: 0;
left: 0;
padding: 0 0 10% 10%;
}
.menu-footer span {
color: var(--colors-contast);
}
.title {
letter-spacing: 0.02em;
font-weight: 900;
font-size: 3rem;
text-transform: uppercase;
}
.menu-social-links {
font-size: 13px;
margin-block: 0.4em 0.7em;
overflow-x: hidden;
white-space: nowrap;
}
.menu-social-links a:hover {
text-decoration: underline;
}
@media screen and (max-width: 786px) {
.menu-content {
width: 100%;
}
}
button[id='burger'] {
position: absolute;
top: 20px;
right: 20px;
z-index: 1000;
}
body{
height: 1500px;
}
body.burgerOpen {
overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.co/gsap@3/dist/gsap.min.js"></script>
<div class='menu-overlay'>
<div class='menu-content'>
<ul class='menu-list'>
<li>
<a href='' class='menu-link title'>About</a>
</li>
<li>
<a href='' class='menu-link title'>Projects</a>
</li>
<li>
<a href='' class='menu-link title'>Contact</a>
</li>
</ul>
</div>
</div>
<button id='burger'>Burger</button>
给任何可能有同样问题的人。我设法将文件上传到我的S3存储桶中。
在github上环顾四周之后,有一个提交不合并会给实际错误提供:
'https://bucket.s3.region.amazonaws.com/file.ext上执行“ putoBject”的错误“ putoBject”; AWS http错误:卷曲错误60:SSL证书问题:无法获得本地发行者证书(请参阅 https://curl.haxx.se/libcurl/c/libcurl-errors.html )for https://bucket.s3.region.amazonaws.com/file.ext'
解决该问题:
我对这个问题有一个非常简单的解决方案。您可以在没有任何证书文件的情况下执行此操作。
在laravel root文件夹中 - &gt; vender-&gt; guzzlehttp-&gt; guzzle-&gt; SRC
Open Client.php
查找$ defaults数组。看起来像这样。
$defaults = [
'allow_redirects' => RedirectMiddleware::$defaultSettings,
'http_errors' => true,
'decode_content' => true,
'verify' => true,
'cookies' => false
];
现在的主要工作是更改验证密钥的值。
'verify' => false,
因此,此后,它不会检查SSL证书是否有卷曲请求。该解决方案对我有用。经过大量研究,我发现了这个解决方案。
注意:'verify'=&gt; false
可以在任何实时或开发服务器中创建安全问题。不要在服务器上尝试此操作。该解决方案仅适用于本地系统。
答案在这里找到:
一个解决方法是删除首选项文件:
~Library/Application Support/BraveSoftware/Brave-Browser/Default/Preferences
导航到〜库:打开查找器,保持“选项”,然后单击菜单上的“转到”菜单。
这是因为您仅定义一个函数而不将其调用代码中的任何位置,
还可以确保在HTML中使用JavaScript文件。了解更多。 https://wwwwwww.w3schools.com/tags/tags/tags/tags/att_script_src.src_src.asp
function click(){
console.log("Test");
}
//Call this function
click();
javascript在这里: javascript函数
您当前尝试不起作用的原因是,PowerShell中的单引号(
'
)字符串是 verbatim strings - 不尝试扩展子表达管道或变量表达。如果您想要一个可扩展的字符串文字而无需逃脱字符串本身中包含的所有双引号(
“
),请使用此处的字符串:The reason your current attempt doesn't work is that single-quoted (
'
) string literals in PowerShell are verbatim strings - no attempt will be made at expanding subexpression pipelines or variable expressions.If you want an expandable string literal without having to escape all the double-quotes (
"
) contained in the string itself, use a here-string:powershell格式为字符串