我有一个稍微不同的解决方案 -
- 简化
fun_insert
函数 sprintf 。 - 在
fun_insert
(j
)中添加了一个附加参数,以便我们可以摆脱storage_med_pt1
。 - 而不是嵌套<代码> 循环我使用了嵌套
sapply
。它以同样的方式工作。
fun_insert <- function(org, i, j, stor) sprintf('%s ~ a%i%i*%s', org, i, j, stor)
#For one value
fun_insert(original_m[1], 1, 1, storage_mod_xm_all[1])
#[1] "BODYSHAME ~ a11*FEAROFSELFCOMPASSION"
#For all of them
c(t(sapply(seq_along(original_m), function(x) {
sapply(seq_along(storage_mod_xm_all), function(y) {
fun_insert(original_m[x], x, y, storage_mod_xm_all[y])
})
})))
#[1] "BODYSHAME ~ a11*FEAROFSELFCOMPASSION" "WBIS_M ~ a21*FEAROFSELFCOMPASSION"
#[3] "BODYSHAME ~ a12*SBOSS" "WBIS_M ~ a22*SBOSS"
一种做到这一点的方法是,在情况下使用情况和使用常规订购的情况下使用案例对项目的订购优先级。这样的优先级将在字母内进行,然后是数字,然后在相应类别中订购
:
select a.*
from t a
order by case when translate(x,'0123456789',' ')<>x then 1 else 0 end
,x
+--------+
| output |
+--------+
| AA |
| AB |
| AC |
| AZ |
| 00 |
| 01 |
| 02 |
| 4 |
+--------+
https://dbfiddle.uk/?rdbms=oracle_11.2&; fiddle = dff7E6805F1B59501D59CB91194CF1A0
就我而言,它无法发现仅仅因为我的当地就有它而在远程环境中都不存在。
因此,我不得不在本地机器上删除宝石library/caches/jetbrains/rubymine2022.3/ruby_stubs/256935961/home/home/ubuntu/.rvm/gems/ruby-3.1.1.4/ruby-debug-debug-iide -3.0.0.beta.6.1/
,用于调试再次工作。
我不太确定您想如何将员工添加到数组中,所以我在这里做了一些假设。
该代码将递归地遍历数组的所有元素,直到找到与父ID匹配的元素。此时,它将指定的项目添加到该“父”的_Children
属性。
注意:如果您喜欢通过参考传递数组,则可以简化这一点。对于此示例,我已经设置了它,以便它不会编辑原始数组(除非您覆盖变量)。
function addChild(array $main, array $item, $parent_id) {
foreach ($main as $key => $element) {
if ($parent_id === $element["id"]) {
// create _children element if not exist
if (!isset($element["_children"])) {
$element["_children"] = [];
}
$element["_children"][] = $item;
// specify $main[$key] here so that the changes stick
// outside this foreach loop
$main[$key] = $element;
// item added - break the loop
break;
}
// continue to check others if they have children
if (isset($element["_children"])) {
$element["_children"] = addChild($element["_children"], $item, $parent_id);
// specify $main[$key] here so that the changes stick
// outside this foreach loop
$main[$key] = $element;
}
}
return $main;
}
$employee = [
"id" => 99,
"name" => "Test Employee",
"parent_id" => 4,
];
$new_rows = addChild($rows, $employee, $employee["parent_id"]);
注意:这使用$ parent_id === $ element [“ id”]
的严格比较,意思。您可以将这些值转换为相同的格式,也可以更改为非图案比较==
。
您可以使用以下类似的方式使用运行计数(假设这是您正在谈论的MS SQL)
SELECT ROW_NUMBER() over(partition by [LineId] order by [LineId]) as DocId,
[LineId],
[Price]
FROM [StackOverflow].[dbo].[RunningCount] order by [LineId]
好的,因此您在代码中使用aria-label
的预期用法有些混乱。
您的代码:
<header class="c-site-header">
<nav id="aria-label">
<a class="main site links" href="#">About Me</a>
<a class="main site links" href="my project">My Projects</a>
<a class="main site links" href="contact me">Contact Me</a>
</nav>
<h1>Welcome To My Page</h1>
</header>
aria-label
本身是位于HTML元素(不是ID)上的属性,仅在看不到元素的文本标签的情况下才能使用。
考虑此示例:
您有一个“关闭”图标的SVG。浏览器只能看到您拥有SVG,无法确定其内容或目的。对于那些可以看到它的人来说,这可能很明显,但是对于那些依靠辅助技术的损害的人来说,您需要提供其他信息。
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 371.23 371.23" style="enable-background:new 0 0 371.23 371.23"...>
您添加的其他信息可以通过多种方式完成,其中之一是aria-label
:
<svg xmlns="http://www.w3.org/2000/svg" aria-label="Close the mobile menu" viewBox="0 0 371.23 371.23" style="enable-background:new 0 0 371.23 371.23"...>
现在辅助技术可以使用标签来解释此元素的作用。
在您的上下文中,您使用的是HTML5标签,这些标签暗示了详细信息,您无需添加其他ARIA信息。
有关ARIA的更多详细信息,它是用法和约束,我建议 mdn的文档。
首先,如果打印出c
,则获得eq(x(t),(f*t/880 + cos(440*t)/440)*sin(440* t))
。要绘制,您需要通过c.rhs
获得此方程的右手侧。
另请注意,(再次,打印)您在c.rhs
中仍然具有符号f
,我们应该用您的数值替换(我将手动输入替换为<<代码> W = 440 )。这样就可以使我们c.rhs.subs(f,w)
。
然后,lambdify正确执行,为我们提供了一个纯粹的数值值,而不是符号值,我们可以通过plt.plot(n,y)
来绘制这些值。
总而言之,
[nav] In [29]: from sympy import *
...: import sympy as sp
...:
...: from sympy.abc import *
...: import numpy as np
...:
...: import matplotlib.pyplot as plt
...: x=sp.Function('x')
...:
...: t=symbols('t')
...: w=440
...:
...: eq= sp. Eq(x(t).diff(t,2)+w**2*x(t)-f*sp .cos(w*t),0)
...: c= sp. dsolve(eq,x(t),ics={x(0):0,x(t).diff(t).subs(t,0):sp .cos(w*t)})
...:
...: d= lambdify(t,c.rhs.subs(f, w),modules='numpy')
...: n= np. arange (0,10,1)
...:
...:
...: y=d(n)
...: plt.plot(n, y)
...: plt.show()
另一个线程可以调用pthread_cancel
在这种情况下waitforsingleobject
将立即返回,并且在您的简单睡眠
时将杀死该线程在未知的时间内。
为什么他们在睡觉(0)
和之前调用
,我不知道。也许您应该直接询问作者是否在乎。我认为他们在那里是有原因的...pthread_testcancel
,如果(s-&gt; evstart)
我从
Quote iCyjoseph :
嗨,
是的,所以将这两个错误组合在一起。
因为客户在第一帧上需要看到相同的html
服务器发送了,以放置事件听众并放置
兄弟姐妹和孩子正确,如果有错误的话
做完,React记录一个错误。这已经发生了
反应17 afaik。问题2与新的渲染根开始了
作为渲染错误,这是不友好的并发功能,因此
水合失败了,它将整个东西扔到窗外。至少这就是我解释第二个错误的方式。很多人
被忽略的错误数字1,在整个2年中,React 17均已发布,
并不是说您做到了,而是很多使用的图书馆,而其他图书馆只是
忽略了他们。可能的工作时间和随机性是最常见产生的两件事
这个。我会这样攻击这个问题:
- 让服务器渲染时间,但以UTC格式
- 可选,放置将其隐藏的CSS,但仍存在于布局(不显示)
- 从客户端,更新到正确的时区,也使时间可见
导入{cssproperties,useffect,usestate}来自“ react”; 导入{example}来自“ ../ Components/example”; const timeDisplay =({time}:{time:number})=&gt; { const [currenttime,setCurrenttime] = usestate((()=&gt; { const hour =(“ 0” + new Date(Time * 1000).getUtchours())。切片(-2); const分钟=(“ 0” + new Date(Time * 1000).getutcminutes())。切片(-2); 返回`$ {hour}:$ {分钟} utc`; }); useeffect(()=&gt; { setCurrenttime(()=&gt; { const hour =(“ 0” + new Date(Time * 1000).gethours())。切片(-2); const分钟=(“ 0” + new Date(Time * 1000).getMinutes())。切片(-2); 返回`$ {hour}:$ {分钟}`; }); }, [时间]); //可选地使此内容占用空间,但保持无形,以避免布局变化 //最好使用CSS课程 const样式:cssproperties = { 可见性:currenttime.ixludes(“ UTC”)? “隐藏”:“可见”, }; 返回 ( &lt; Actip&gt; &lt; p style = {style}&gt; {currenttime}&lt;/p&gt; &lt;/apress&gt; ); };
我建议还会在DateTimeFormat API中进行混合,
https://developer.mozilla.org/en-us/docs/web/javascript/reference/reference/global_objects/intl/datementl/datement emptimeformat ,
可以照顾您的时区:const date = new Date(date.utc(2012,11,20,3,0,0,0,200)); 选项= { 小时:“数字”,分钟:“数字”,第二:“数字”, TimeZoneName:“ Short” }; console.log(new Intl.dateTimeFormat('sv-se',options).format(date));
如果我将上述运行到 repl ,我得到3:00:00 am am am am am a am这是
您的服务器发送的内容),但是如果我在获得的浏览器上运行它,
4:00:00 CET。您页面的源代码包含服务器所看到的时间。
由于用户从不同的时区到达您,您必须
说明您显示UTC的框架,然后显示时间
用户时区。将其与CSS可见性结合好,
因为您可以避免布局变化等等,所以时间将花在
位置,但看不到。机器人,爬行者仍然会看到时间,对于JS禁用的用户,
您可以添加一个使日期再次可见的标签。
我假设您的意思是您发现的第一个数字是0(否则它应该返回“ J02”的false,因为02是第一个数字)
x = "J02"
def not_starting_zero(m):
for char in m:
if char.isdigit() == True:
if char == "0":
return True
else:
return False
return False
not_starting_zero(x)
这项工作起作用,因为一旦在函数中执行返回后,该函数的其余部分就不会执行。希望这能解决您的怀疑。
您不需要制作数字数字,因为您只需要检查字符串中的第一个数字即可。如果它的0返回true否则返回false。
尝试使用级联参数将多个组件一起“将多个组件连接在一起,并且两种方式绑定并不总是做事的最佳方法,尤其是一个页面中子组件的子组件(看来您正在尝试从显示的信息中执行在问题中)。
使用标准事件模型有一种替代方法。
我的债务人
public class Debtor
{
public Guid Id { get; set; }
public string? Name { get; set; }
}
a级债务人查看服务:
public class DebtorViewService
{
public Debtor Record { get; private set; } = default!;
public event EventHandler<Debtor>? DebtorChanged;
public DebtorViewService()
{
// Get and assign the Debtor Store DI service
}
public async ValueTask GetCurrentDebtor(Guid debtor)
{
// Emulate getting the Debtor from the Debtor Service
await Task.Delay(1000);
this.Record = new Debtor() { Name=$"Fred {DateTime.Now.ToLongTimeString()}", Id = Guid.NewGuid()};
this.DebtorChanged?.Invoke(this, this.Record);
}
}
在这样的服务中注册:
builder.Services.AddScoped<DebtorViewService>();
获得债务人的组件:
getDebtor.razor.razor
@inject DebtorViewService Service
<div class="m-2 p-3 bg-dark text-white">
<h5>GetDebtor Component</h5>
<div>
<button class="btn btn-secondary" @onclick=this.GetCurrentDebtor>Get Debtor</button>
</div>
</div>
@code {
private async Task GetCurrentDebtor()
=> await Service.GetCurrentDebtor(Guid.Empty);
}
是向债务人展示的组件:
showdebtor。 Razor
@inject DebtorViewService Service
@implements IDisposable
<div class="m-2 p-3 bg-info">
<h5>ShowDebtor Component</h5>
@if (this.Service.Record is not null)
{
<div>
Id : @this.Service.Record.Id
</div>
<div>
Name : @this.Service.Record.Name
</div>
}
</div>
@code {
protected override void OnInitialized()
=> this.Service.DebtorChanged += this.OnDebtorChanged;
private void OnDebtorChanged(object? sender, Debtor value)
=> this.InvokeAsync(this.StateHasChanged);
public void Dispose()
=> this.Service.DebtorChanged -= this.OnDebtorChanged;
}
和一个演示页面:
@page "/"
<PageTitle>Index</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.
<GetDebtor />
<ShowDebtor />
<SurveyPrompt Title="How is Blazor working for you?" />
@code{
}
数据和更改事件现在以一个每个人都可以访问的单个共享(范围)DI服务实例。
您应该能够根据此代码构建组件。
有时,复选框无法直接交互。您可能需要单击复选框旁边的标签/文本。
或者可能是您必须等到元素可单击,因为您的循环运行。
谢谢@windowsill的帮助。
export interface FinancialData {
handleViewData: () => void;
symbol: string;
name: string;
stockExchange: string;
exchangeShortName: string;
currency: string;
}
export const useGetFinancialDataKey = 'get-financial-data';
const useGetFinancialData = (
options: UseQueryOptions<FinancialData[], string> = {}
): UseQueryResult<FinancialData[], string> =>
useQuery<FinancialData[], string>(
useGetFinancialDataKey,
async () =>
(await axiosInstance.get<FinancialData[]>('https://financialmodelingprep.com/api/v3/search?query=AA&limit=10&exchange=NASDAQ&apikey=blahblah'
))
.data,
options
);
export default useGetFinancialData;
您的方法具有类型
供应商&lt; integer&gt;
的一个参数,因此您有三个选择将作为参数传递给此方法的选择(这个想法是通过一个实现功能接口供应商的类的实例):方法参考
匿名内部类
Your method have one parameter of type
Supplier<Integer>
so you have three choices to pass as argument to this method (the idea is to pass an instance of a class who implements the functional interface Supplier):A lambda expression
A method reference
An anonymous inner class
供应商的Java功能接口&lt; t&gt;无法编译非lambda