梦回梦里

文章 评论 浏览 27

梦回梦里 2025-02-20 17:35:01

您正在寻找

联合类型是由两种或多种类型形成的类型,代表可能是这些类型中任何一种的值

type DateType = 'day' | 'week';
const date: DateType = 'day';

You are looking for Union types

A union type is a type formed from two or more other types, representing values that may be any one of those types

type DateType = 'day' | 'week';
const date: DateType = 'day';

如何为单个变量而不是对象创建接口

梦回梦里 2025-02-19 23:35:57

仅在您不关心Internet Explorer 6和7时垂直居中

,您可以使用涉及两个容器的技术。

外部容器:

  • 应该具有显示:表;

内置容器:

  • 应有display:table-cell;
  • 应具有fertical-align:中间;

内容框:

  • 应该具有显示:inline-block;

您可以将您想要的任何内容添加到内容框中,而无需关心其宽度或高度!

演示:

body {
    margin: 0;
}

.outer-container {
    position: absolute;
    display: table;
    width: 100%; /* This could be ANY width */
    height: 100%; /* This could be ANY height */
    background: #ccc;
}

.inner-container {
    display: table-cell;
    vertical-align: middle;
}

.centered-content {
    display: inline-block;
    background: #fff;
    padding: 20px;
    border: 1px solid #000;
}
<div class="outer-container">
   <div class="inner-container">
     <div class="centered-content">
        Malcolm in the Middle
     </div>
   </div>
</div>

另请参见 这个小提琴


水平和垂直居中,

如果您想水平和垂直居中,则还需要以下内容。

内部容器:

  • 应具有文本壁:中心;

内容框:

  • 应该重新调整水平文本对齐,例如text-align:left; left; ore代码> text-align:正确; ,除非您希望文本为中心

demo:

body {
    margin: 0;
}

.outer-container {
    position: absolute;
    display: table;
    width: 100%; /* This could be ANY width */
    height: 100%; /* This could be ANY height */
    background: #ccc;
}

.inner-container {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
}

.centered-content {
    display: inline-block;
    text-align: left;
    background: #fff;
    padding: 20px;
    border: 1px solid #000;
}
<div class="outer-container">
   <div class="inner-container">
     <div class="centered-content">
         Malcolm in the Middle
     </div>
   </div>
</div>

另请参见 这个小提琴

Centering only vertically

If you don't care about Internet Explorer 6 and 7, you can use a technique that involves two containers.

The outer container:

  • should have display: table;

The inner container:

  • should have display: table-cell;
  • should have vertical-align: middle;

The content box:

  • should have display: inline-block;

You can add any content you want to the content box without caring about its width or height!

Demo:

body {
    margin: 0;
}

.outer-container {
    position: absolute;
    display: table;
    width: 100%; /* This could be ANY width */
    height: 100%; /* This could be ANY height */
    background: #ccc;
}

.inner-container {
    display: table-cell;
    vertical-align: middle;
}

.centered-content {
    display: inline-block;
    background: #fff;
    padding: 20px;
    border: 1px solid #000;
}
<div class="outer-container">
   <div class="inner-container">
     <div class="centered-content">
        Malcolm in the Middle
     </div>
   </div>
</div>

See also this Fiddle!


Centering horizontally and vertically

If you want to center both horizontally and vertically, you also need the following.

The inner container:

  • should have text-align: center;

The content box:

  • should re-adjust the horizontal text-alignment to for example text-align: left; or text-align: right;, unless you want text to be centered

Demo:

body {
    margin: 0;
}

.outer-container {
    position: absolute;
    display: table;
    width: 100%; /* This could be ANY width */
    height: 100%; /* This could be ANY height */
    background: #ccc;
}

.inner-container {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
}

.centered-content {
    display: inline-block;
    text-align: left;
    background: #fff;
    padding: 20px;
    border: 1px solid #000;
}
<div class="outer-container">
   <div class="inner-container">
     <div class="centered-content">
         Malcolm in the Middle
     </div>
   </div>
</div>

See also this Fiddle!

如何使用CSS垂直将DIV元素集成为DIV元素?

梦回梦里 2025-02-19 17:12:16

丹尼尔,很棒的解释!在此上有几个单词,<代码>的良好列表此在事件处理程序的情况下执行上下文指针。

用两个词,在JavaScript中指向对象(或执行上下文)运行当前函数,并且总是只读,您都无法设置它(这样的尝试将尝试 左侧无效”消息。

最终以“分配中的 覆盖以前和之前附加的任何其他处理程序,因此请小心,最好避免在线事件委托。
感谢Zara Alaverdyan,他通过反对辩论启发了我进入这个例子列表:)

  • el.onclick = foo; //在foo -obj
  • el.onclick = function(){this.style.color ='#fff';} // obj
  • el.onclick = function(function(function(function)) ){dosomething();} //在dosomething-
    window
  • el.addeventlistener('click',foo,false)//在foo -obj
  • el.attachevent('onclick,function(){// this}' )//窗口,所有
    符合IE:)
  • &lt; button onclick =“ this.style.color ='#fff';”&gt; // obj
  • &lt; button onclick =“ foo”&gt; //在foo-窗口中,但是您可以lt;按钮
    onClick =“ foo(this)”&gt;

Daniel, awesome explanation! A couple of words on this and good list of this execution context pointer in case of event handlers.

In two words, this in JavaScript points the object from whom (or from whose execution context) the current function was run and it's always read-only, you can't set it anyway (such an attempt will end up with 'Invalid left-hand side in assignment' message.

For event handlers: inline event handlers, such as <element onclick="foo">, override any other handlers attached earlier and before, so be careful and it's better to stay off of inline event delegation at all.
And thanks to Zara Alaverdyan who inspired me to this list of examples through a dissenting debate :)

  • el.onclick = foo; // in the foo - obj
  • el.onclick = function () {this.style.color = '#fff';} // obj
  • el.onclick = function() {doSomething();} // In the doSomething -
    Window
  • el.addEventListener('click',foo,false) // in the foo - obj
  • el.attachEvent('onclick, function () { // this }') // window, all the
    compliance to IE :)
  • <button onclick="this.style.color = '#fff';"> // obj
  • <button onclick="foo"> // In the foo - window, but you can <button
    onclick="foo(this)">

“这个”如何关键字工作,什么时候应该使用?

梦回梦里 2025-02-19 09:28:06

您可以首先反向字典然后喜欢以下:

import numpy as np
nodes={(0, 0): 1,(0, 1): 2,(1, 0): 3,(1, 1): 4}
rvs_nodes = {v:k for k,v in nodes.items()}

I2=np.array([[1,2],[1,3],[2,4],[3,4]])

I3 = [[rvs_nodes[node[0]], rvs_nodes[node[1]]] for node in I2]
print("I3 =",I3)

输出:

I3 = [[(0, 0), (0, 1)], [(0, 0), (1, 0)], [(0, 1), (1, 1)], [(1, 0), (1, 1)]]

You can first reverse dictionary then do like below :

import numpy as np
nodes={(0, 0): 1,(0, 1): 2,(1, 0): 3,(1, 1): 4}
rvs_nodes = {v:k for k,v in nodes.items()}

I2=np.array([[1,2],[1,3],[2,4],[3,4]])

I3 = [[rvs_nodes[node[0]], rvs_nodes[node[1]]] for node in I2]
print("I3 =",I3)

Output:

I3 = [[(0, 0), (0, 1)], [(0, 0), (1, 0)], [(0, 1), (1, 1)], [(1, 0), (1, 1)]]

在Python中提取节点索引

梦回梦里 2025-02-19 05:42:47

我遇到了同样的问题,我通过添加“ - 简化”来解决它

i had the same issue, i solved it by adding "--simplify" for the Export

错误在OpenCV Python中加载Yolov5,如何解决?

梦回梦里 2025-02-19 04:21:02

这应该有效:

#include<stdio.h>
void listNumbersAsc(int start, int end);
int main()
{
    int x,y;
    printf("Enter the range of numbers maintaining start at first and end at second:");
    scanf("%d %d",&x,&y);

   listNumbersAsc(x, y);
}
void listNumbersAsc(int start, int end){
    
    int i,s,e;
    
    if(start<=end){
        s=start;
        e=end;
    }
    else{
        s=end;
        e=start;
    }

    for(i=s; i<=e; i++){
        printf("%d ",i);
    }
}

如果语句中的listNumbersASc函数不正确。

还在scanf中添加了两个%d(“%d%d”,&amp; x,y y)以分开两个数字。

This should work:

#include<stdio.h>
void listNumbersAsc(int start, int end);
int main()
{
    int x,y;
    printf("Enter the range of numbers maintaining start at first and end at second:");
    scanf("%d %d",&x,&y);

   listNumbersAsc(x, y);
}
void listNumbersAsc(int start, int end){
    
    int i,s,e;
    
    if(start<=end){
        s=start;
        e=end;
    }
    else{
        s=end;
        e=start;
    }

    for(i=s; i<=e; i++){
        printf("%d ",i);
    }
}

You if statement in listNumbersAsc function wasn't correct.

Also added a space between two %d in scanf("%d %d",&x,&y) to separate two numbers.

void函数用法问题,我是新手

梦回梦里 2025-02-18 21:39:40

更改list = {18,23,45,67,230}

list=[18,23,45,67,230]

Change list={18,23,45,67,230}
to

list=[18,23,45,67,230]

如何使循环列举列表中的对象?

梦回梦里 2025-02-18 19:18:25

设法使它正常工作!

df=df %>%
     group_by(period) %>%
     mutate(series = match(month, unique(month)))

Managed to get it working!

df=df %>%
     group_by(period) %>%
     mutate(series = match(month, unique(month)))

沿着R沿2个层次进行测序

梦回梦里 2025-02-18 09:56:50

使用字符串:

import numpy as np

arr = np.array([[0,  1,  0], [ 0,  0,  0], [ 1,  1,  1], [ 0,  1,  1]])

binaries = []
for idx, row in enumerate(arr):
    strings = [str(integer) for integer in row]
    a_string = "".join(strings)
    binaries.append(a_string)

>>> binaries
>>> ['010', '000', '111', '011']

Using strings:

import numpy as np

arr = np.array([[0,  1,  0], [ 0,  0,  0], [ 1,  1,  1], [ 0,  1,  1]])

binaries = []
for idx, row in enumerate(arr):
    strings = [str(integer) for integer in row]
    a_string = "".join(strings)
    binaries.append(a_string)

>>> binaries
>>> ['010', '000', '111', '011']

在2D数组中整理行条目

梦回梦里 2025-02-18 00:13:15

IDE更有可能向您展示test_obj.b的值是什么。为此,test_obj.b 中获取值。由于b是属性还是@property,debugger本质上只是test_obj.b您,这给了它值'b'

函数def b完全按照您从任何其他普通函数中期望的方式工作;只是调试器/IDE隐含地为您调用它。

More likely, the IDE is trying to show you what the value of test_obj.b is. For that it gets the value from test_obj.b. Since it doesn't make much of a difference whether b is an attribute or a @property, the debugger essentially just does test_obj.b for you, which gives it the value 'b'.

The function def b works exactly as you might expect from any other ordinary function; it's just that the debugger/IDE implicitly invokes it for you.

python @properties如何以及何时评估

梦回梦里 2025-02-17 14:15:52

您正在创建两个不同的对象。

  1. b具有y值= 10
  2. C的B值= 2 = 2且z = 3

您创建的B和C对象之间没有关系。
因此,当您调用c.m3()时,它会乘以2*3。

您不需要创建B对象,
由于您通过super()分配C对象的y值。
取而代之的是,您只需要创建一个具有值10和3的C对象。

另一个问题是,在C类中,您有int y,z;

  1. 他们应该不是私人的。
  2. Y值在B类中传递,因此不需要Y值。

You are creating two different objects.

  1. B that has y value = 10
  2. C that has y value = 2 and z = 3

The b and c objects you have created have no relationship between them.
So when you call c.m3() it multiplies 2*3.

You do not need to create a B object,
since you assign the y value of C object by super().
Instead you just have to create a C object with values 10 and 3.

Also another problem is that on class C you have int y, z;.

  1. They are not private when they should be.
  2. Y value is passed on the parent class B, so there is no need for the y value.

在子类的方法中使用类的私人变量

梦回梦里 2025-02-17 00:17:01

我浪费了3天的错误,但终于找到了解决方案。

您无法从前端侧处理它,因为Instagram API仅接受一种媒介的请求,为此,您必须在后端部署API才能解决此问题。

一旦您将API部署在后端,后端将要求访问访问权限,您的问题将得到解决。

I have wasted 3 days on this error but finally got the solution.

You cannot handle it from front-end side because Instagram API only accepts requests from one medium and for that you will have to deploy your API at backend to resolve this issue.

Once you will deploy the API at backend and backend will request for the access_token , your issue will be resolved.

React JS Cors -Origin -Instagram基本显示API

梦回梦里 2025-02-17 00:11:05

这是使用JavaScript和解决方案“数据”的简单实现,是您的JSON数据

    let findstring="loks3123";
    for(var i=0;i<data.length;i++){
        let sku=data[i];
        for(var j=0;j<sku.plans.length;j++){
            let plans=sku.plans[j];
            if(plans.plan.planId==findstring){
                console.log("skuId:"+sku.skuId);
            }
        }
    }

Here is a simple implementation for your problem using javascript and in the solution 'data' is your json data

    let findstring="loks3123";
    for(var i=0;i<data.length;i++){
        let sku=data[i];
        for(var j=0;j<sku.plans.length;j++){
            let plans=sku.plans[j];
            if(plans.plan.planId==findstring){
                console.log("skuId:"+sku.skuId);
            }
        }
    }

JSONPATH:如何过滤嵌套数组?

梦回梦里 2025-02-16 20:40:35

一个(包括我)可能会争辩说,如果您想在本地重试,您应该简单地自己处理任务中的异常,尤其是考虑到您想在两次恢复之间保留某些状态。

据我所知,芹菜不会为您做。如果我没记错的话,您可以提出功能请求,并希望他们在可预见的将来这样做。

One (me included) could argue that if you want to re-try locally you should simply handle the exception(s) in your task by yourself, especially considering that you want to preserve some states between retries.

As far as I know Celery will not do it for you. If I am not mistaken you could file a feature request and hope they do it in foreseeable future.

芹菜在本地重试任务?

梦回梦里 2025-02-15 22:49:21

使用功能。

async function makeHttpCall(successCallbk) {
    var response = await fetch(...arguments);
    if(response.ok) {
        sessionStorage.setItem('token', response['Refresh-Token']);
        successCallback.call();
    } else {
        setErrors(response);
        console.log(response);
    }
}
    

Use a function.

async function makeHttpCall(successCallbk) {
    var response = await fetch(...arguments);
    if(response.ok) {
        sessionStorage.setItem('token', response['Refresh-Token']);
        successCallback.call();
    } else {
        setErrors(response);
        console.log(response);
    }
}
    

在React中,是否有一种方法可以将过滤器应用于通过提取获得的响应?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文