野の

文章 评论 浏览 30

野の 2025-02-06 07:14:20

更容易的方法是使用两页进行操作:

  • 第一页:用户可以选择加载数据
  • 第二页:加载数据并显示该数据,

如果您想在同一页面上执行此操作应该加载数据,然后您需要使用JavaScript / Ajax加载和根据用户输入(例如单击按钮)加载和更新当前页面(或其中一部分)。

有多种实施方法。以下是一些示例:

我建议您推荐htmx,因为它允许您执行此操作不必编写任何JavaScript,并且与Django模板一起运行良好。

The easier approach is to do this with two pages:

  • First page: User can choose to load the data
  • Second page: Loads the data and shows it

If you want to do this on the same page you normally put a div on your page where the data should be loaded and then you need to use Javascript / AJAX to load and update your current page (or a part of it) based on user input like a clicked button.

There are multiple ways to implement this. Here are some examples:

I would recommend HTMX, because it allows you to do this without having to write any JavaScript and it works great together with Django templates.

如何在Django View中从Postgres存储大型数据集?

野の 2025-02-06 01:11:13

您的行:

x=xlsread('Training');
y=xlsread('Output');
t=xlsread('Test');

现在将来自Things plate plase频道。这是MATLAB中的ThingsPeakRead的一个示例:

data = thingSpeakRead(12397,'Fields',[1,4],NumPoints=3,OutputFormat='TimeTable')

这是 thingspeakeakread )。

Your lines:

x=xlsread('Training');
y=xlsread('Output');
t=xlsread('Test');

will now come from a ThingSpeak channel. Here's an example of thingSpeakRead in MATLAB:

data = thingSpeakRead(12397,'Fields',[1,4],NumPoints=3,OutputFormat='TimeTable')

Here's the doc for thingSpeakRead.

Tressepeak频道上的前馈神经网络

野の 2025-02-05 08:18:29

那些说两个完全不同的事情。第二个采用三个对象(first_name,midder_name,last_name),然后将它们构建成元组,然后将其分配给 name 。这显然不是您想要的,因为这三个名字不存在。您的第一个示例将变量 name (确实存在)的三个部分(确实存在),并将它们拆开到这三个对象中。您的第二个示例不是您编写作业语句的方式。任务将右边的东西分配给左侧的东西。

毕竟,您写信:

num = 3

不对吗

3 = num

Those say two entirely different things. The second one takes three objects (first_name, middle_name, last_name), then builds them into a tuple, and assigns that to name. That's clearly not what you want, since those three names do not exist. Your first example takes the three parts of the variable name (which does exist), and unpacks them into those three objects. Your second sample is just not the way you write an assignment statement. An assignment takes what's on the RIGHT, and assigns it into what's on the LEFT.

After all, you write:

num = 3

and not

3 = num

right?

为什么需要在等价(=)的左侧新变量名称?

野の 2025-02-05 04:00:17

您正在尝试的是可能的。但是,根据您使用的方法,这是错误的。

  1. 因此,首先,您不使用绑定,因此我们将使用它。
  2. 您没有将FAB添加到视图中,因此我们将添加。

现在,为了解决问题,我们将使用上述最终代码进行上述两项事情:

public class MainActivity extends AppCompatActivity {

    private AppBarConfiguration appBarConfiguration;
    private ActivityMainBinding binding;

    private WebView mWebview ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityMainBinding.inflate(getLayoutInflater());

        setContentView(binding.getRoot());

        mWebview  = new WebView(this);
   
        binding.getRoot().addView(mWebView);

        mWebview.loadUrl("https://www.Camp-Ann.com/");

        FloatingActionButton reloadTab = getReloadFab(this);

        binding.getRoot().addView(reloadTab);
        
    }

    public FloatingActionButton getReloadFab(Context context) {
        FloatingActionButton fab = new FloatingActionButton(context);

        fab.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                mWebview.loadUrl( "javascript:window.location.reload( true )" );
            }
        });
        return fab;
    }
}

What you are trying is possible. But, according to the approach you are using, it is wrong.

  1. So, first of all, you are not using binding so, we will use that.
  2. You are not adding the fab to the view, so we will add that.

Now, to solve the problem, we will do both the things mentioned above with our final code looking like this:

public class MainActivity extends AppCompatActivity {

    private AppBarConfiguration appBarConfiguration;
    private ActivityMainBinding binding;

    private WebView mWebview ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityMainBinding.inflate(getLayoutInflater());

        setContentView(binding.getRoot());

        mWebview  = new WebView(this);
   
        binding.getRoot().addView(mWebView);

        mWebview.loadUrl("https://www.Camp-Ann.com/");

        FloatingActionButton reloadTab = getReloadFab(this);

        binding.getRoot().addView(reloadTab);
        
    }

    public FloatingActionButton getReloadFab(Context context) {
        FloatingActionButton fab = new FloatingActionButton(context);

        fab.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                mWebview.loadUrl( "javascript:window.location.reload( true )" );
            }
        });
        return fab;
    }
}

如何在编程中添加浮动界

野の 2025-02-04 19:17:41

在关键字中使用您可以在列表中迭代单个元素。因此,您可以尝试一下:

for body in splited_body:
    for msg in body:
        if msg.strip() == 'endmsg':
            break
        print(msg)

Using in keyword you can iterate individual elements in a list. So you can try this out:

for body in splited_body:
    for msg in body:
        if msg.strip() == 'endmsg':
            break
        print(msg)

从2D列表中提取项目

野の 2025-02-04 15:18:54

我猜这个问题是由React版本引起的。

现在我的index.js代码是

const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

,但是当我将代码更改为

const rootElement = document.getElementById("root");

ReactDOM.render(
  <StrictMode>
    <App />
  </StrictMode>,
  rootElement
)

So时,我必须将React版本降至16或17
或者
我必须在版本-18上找到另一个解决方案

I guess this problem cause by React version.

now my index.js code is

const root = ReactDOM.createRoot(document.getElementById('root'));

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

but it is shown when I changed the code to

const rootElement = document.getElementById("root");

ReactDOM.render(
  <StrictMode>
    <App />
  </StrictMode>,
  rootElement
)

so in my opinion, I have to downgrade React version to 16 or 17
OR
I have to find another solution on version-18

标记不使用 @react-google-maps/api渲染

野の 2025-02-04 14:58:50

代码部分

columns = pd.Index(['A_0', 'A_1', 'A_2', 'A_3', 'B_0', 'B_1', 'B_2', 'B_3'], dtype='string')
values = np.array([[ 3.,  4.,  5.,  6., np.nan,  1.,  4.,  5.],
                 [ 8.,  5.,  3.,  1.,  0.,  8.,  6.,  4.],
                 [ 7.,  9.,  1.,  6.,  1.,  0.,  2.,  3.],
                 [ 5., np.nan,  9.,  1.,  0.,  3.,  8.,  3.]],
                dtype=float)
## Or retrive from raw DataFrame if already exists
# columns = df_raw.columns
# values = df_raw.values

## Construct MultiIndex
mi = pd.MultiIndex.from_tuples((s.split("_") for s in columns))

## Construct DataFrame
df = pd.DataFrame(values, columns=mi)

## reshape: stack level=1 (2nd row) of columns to index
df_result = df.stack(level=1)

>>> df_result
       A    B
0 0  3.0  NaN
  1  4.0  1.0
  2  5.0  4.0
  3  6.0  5.0
1 0  8.0  0.0
  1  5.0  8.0
  2  3.0  6.0
  3  1.0  4.0
2 0  7.0  1.0
  1  9.0  0.0
  2  1.0  2.0
  3  6.0  3.0
3 0  5.0  0.0
  1  NaN  3.0
  2  9.0  8.0
  3  1.0  3.0

解释

步骤:

  1. flat Index

    构建多索引

    pandas提供了4种构建多索引的内置方法;
    在这里使用from_tuples表单
    doc:

    • from_arrays ::
      输入 [[X1,X2,...],[Y1,Y2,...]]
      输出 [[x1,y1],[x2,y2],...]

    • from_tuples ::
      输入 [[X1,Y1],[X2,Y2],...]
      输出相同

    • from_frame ::
      传输 dataframes.values to MultiIndex

    • from_product ::
      像数组一样输入,但将它们拉动到输出。
      例如输入 [[X1,X2],[Y1,Y2,Y3]]
      输出

    MultiIndex([[('x1','y1'),
    ('x1','y2'),
    ('x1','y3'),
    ('x2','y1'),
    ('x2','y2'),
    ('x2','y3')],

  2. 构造新的数据框架,并通过stack

    重新设计

    请参阅RESHAPE/PIVOT主题的用户指南:
    doc: https://pandas.pydata.orgg/docs/docs/docs/user_guide/user_guide/resreshaping.htmpr << /a>


code part

columns = pd.Index(['A_0', 'A_1', 'A_2', 'A_3', 'B_0', 'B_1', 'B_2', 'B_3'], dtype='string')
values = np.array([[ 3.,  4.,  5.,  6., np.nan,  1.,  4.,  5.],
                 [ 8.,  5.,  3.,  1.,  0.,  8.,  6.,  4.],
                 [ 7.,  9.,  1.,  6.,  1.,  0.,  2.,  3.],
                 [ 5., np.nan,  9.,  1.,  0.,  3.,  8.,  3.]],
                dtype=float)
## Or retrive from raw DataFrame if already exists
# columns = df_raw.columns
# values = df_raw.values

## Construct MultiIndex
mi = pd.MultiIndex.from_tuples((s.split("_") for s in columns))

## Construct DataFrame
df = pd.DataFrame(values, columns=mi)

## reshape: stack level=1 (2nd row) of columns to index
df_result = df.stack(level=1)

>>> df_result
       A    B
0 0  3.0  NaN
  1  4.0  1.0
  2  5.0  4.0
  3  6.0  5.0
1 0  8.0  0.0
  1  5.0  8.0
  2  3.0  6.0
  3  1.0  4.0
2 0  7.0  1.0
  1  9.0  0.0
  2  1.0  2.0
  3  6.0  3.0
3 0  5.0  0.0
  1  NaN  3.0
  2  9.0  8.0
  3  1.0  3.0

Explain

Steps:

  1. Construct MultiIndex from flat Index

    Pandas provides 4 builtin method to construct MultiIndex;
    Here use from_tuples form
    doc: https://pandas.pydata.org/docs/reference/api/pandas.MultiIndex.from_tuples.html

    • from_arrays ::
      input [[x1, x2, ...], [y1, y2, ...]]
      output [[x1, y1], [x2, y2], ...]

    • from_tuples ::
      input [[x1, y1], [x2, y2], ...]
      output same

    • from_frame ::
      Transfer DataFrames.values to MultiIndex

    • from_product ::
      input like arrays, but zip them to output.
      e.g. input [[x1, x2], [y1, y2, y3]]
      output

    MultiIndex([('x1', 'y1'),
    ('x1', 'y2'),
    ('x1', 'y3'),
    ('x2', 'y1'),
    ('x2', 'y2'),
    ('x2', 'y3')],
    )

  2. Construct new DataFrame and reshape by stack

    See User Guide on reshape/pivot topic:
    doc: https://pandas.pydata.org/docs/user_guide/reshaping.html

如何将数据框中的多组列组合到单个列?

野の 2025-02-04 14:51:43

在每个盒子中添加一个刚性体,解决了我的问题。

编辑:嗯,只有当我不按照上面显示的拳击表格检查时,它才能起作用。当我将其放入更新之前,它可以在下一个帧中调用。

因此,通过使用刚性芽,它仍然不会在确切的框架上击中,而是在下一个框架上!因此,我通过打电话给Coroutine并等待一个帧来解决我的问题。

Adding a rigidbody to each box fixed my problem.

Edit: Well, it only works when I dont put the Boxcast check like shown above. It works when I put it in Update before the movingblocks method which is called on the next frame.

So by using Rigidbodys it still does not hit on the exact frame but on the next one! So I fixed my problem with a workaround by calling a Coroutine and waiting for one frame.

当对象交换位置时,​​raycasthit不会返回

野の 2025-02-04 14:15:15

而不是{导入'antd/dist/antd.css'}导入此命令
{导入'antd/dist/antd.min.css'}

不要用卷曲括号/

复制

Instead of {import 'antd/dist/antd.css'} Import this command
{import 'antd/dist/antd.min.css'}

Not to copy with curly braces/

ANTD不支持我的固定URL

野の 2025-02-04 11:30:32

箭头功能不会绑定到计算的

尝试:

startLTEndDate() {    
  return(Date.parse(this.dateStart) < Date.parse(this.dateEnd))
}

Arrow function wouldn't bind this for Computed

Try:

startLTEndDate() {    
  return(Date.parse(this.dateStart) < Date.parse(this.dateEnd))
}

vue.js计算的布尔不正确

野の 2025-02-04 11:01:25

加入了永无止境的问题列表。如果您遇到了以下错误,请检查您的导入。

无法从来源加载函数定义:firebaseError:无法从源加载函数定义:无法从​​函数来源生成清单来源:typeError:无法读取未定义的属性(读取'insernal')

我注意到一些过时的admin SDK说明具有以下内容:

import {initializeApp} from "firebase-admin";

正确的导入是:

import {initializeApp} from "firebase-admin/app";

Adding to the never ending list of problems. If you get something like the below error, check your imports.

Failed to load function definition from source: FirebaseError: Failed to load function definition from source: Failed to generate manifest from function source: TypeError: Cannot read properties of undefined (reading 'INTERNAL')

I noticed some outdated Admin SDK instructions had the following:

import {initializeApp} from "firebase-admin";

Where as the correct import is:

import {initializeApp} from "firebase-admin/app";

firebase云错误无法从源加载功能定义

野の 2025-02-04 10:06:53

似乎我找到了一个解决方案:

branch-overrides:
  - master: # Modification of steps/triggers to apply with Git master branch builds only!
      triggers:
        - polling: # Launch job every wednesday morning
            cron: 0 30 8 ? * WED

不幸的是,这种修改 bamboo.yml 本身 do 不是 也不触发构建在下周三!至少根据我的经验,您必须提交“其他东西”(例如源代码文件)才能使竹子认识到您希望在每个星期三早上启动 Master 分支机构的愿望。

基督徒

更新2022-05-25 由于未知原因而行不通>发生。

诡异的。

Seems I've found a solution:

branch-overrides:
  - master: # Modification of steps/triggers to apply with Git master branch builds only!
      triggers:
        - polling: # Launch job every wednesday morning
            cron: 0 30 8 ? * WED

Unfortunately, this modification of bamboo.yml itself does not trigger a build, nor does it launch the job on next wednesday! At least according to my experience, you have to commit "something else" (like source code files) to get Bamboo recognize your wish to launch build of master branch every wednesday morning.

Christian

Update on wednesday, 2022-05-25: Doesn't work for unknown reasons, I think cron expression should make Bamboo launch build this morning, but it doesn't happen.

Weird.

bamboo build yaml:仅在特定的bitbucket git分支上通过cron触发构建

野の 2025-02-04 08:12:40

您可以升级Gherkin的版本:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>23.0.0</version>
</dependency>

You can upgrade version of Gherkin:

<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>gherkin</artifactId>
    <version>23.0.0</version>
</dependency>

无法解决[IO.Cucumber:Cucumber -Core:JAR:7.3.4 - &GT; IO.Cucumber:消息:JAR:18.0.0

野の 2025-02-04 05:25:47

只有在您的DOM中实际使用的WebFont才会加载。
您可以在Chromes Dev工具网络选项卡中检查此。
(我认为它在Chrome中适合您,因为您可能在本地安装了“ Montserrat”)。

为确保字体已加载,您可以通过JS <<<<代码> fontface() 方法。

工作示例

const canvas = document.querySelector("canvas");
const context = canvas.getContext("2d");
context.width = document.body.clientWidth;
context.height = document.body.clientHeight;

let fontUrl =  "https://fonts.gstatic.com/s/montserrat/v24/JTUFjIg1_i6t8kCHKm459Wx7xQYXK0vOoz6jqw16WXh0pg.woff2";
let fontFamily = "Montserrat";
let fontOptions = {
  weight: 900,
  style: "italic"
};
loadFonts(fontFamily, fontUrl, fontOptions);

async function loadFonts(fontFamily, fontUrl, fontOptions) {
  const font = new FontFace(fontFamily, `url(${fontUrl})`);
  font.weight = fontOptions.weight ? fontOptions.weight : 400;
  font.style = fontOptions.style ? fontOptions.style : "normal";
  // wait for font to be loaded
  await font.load();
  document.fonts.add(font);
  // apply font styles to canvas
  canvas.classList.add("fonts-loaded");
  canvas.setAttribute(
    "style",
    `font-family:${fontFamily}; font-weight:${fontOptions.weight}; font-style:${fontOptions.style}`
  );

  drawText();
}

function drawText() {
  context.font = "48px Montserrat";
  context.fontWeight = 900;
  context.fontStyle = "italic";
  context.fillStyle = "red";
  context.textAlign = "center";
  context.textBaseline = "middle";
  context.fillText("Hamburg", 150, 50);
}
canvas {
  height: 50vh;
  border: 1px solid red
}

.fonts-loaded {
  border: 1px solid green;
}
<canvas class="game" />

  1. 我们正在将字体文件加载到 async函数

    (只需打开Goog​​le字体CSS(例如 https:// ?family = montserrat:900i )要获取实际的字体文件URL)
  2. 一旦加载字体后,我们将所需的字体样式属性应用于 Canvas element(通过设置Inline样式)(您也可以使用类)
  3. 现在我们可以在画布上绘制文字

A webfont will only be loaded if it's actually used in your DOM.
You can check this in chromes dev tool network tab.
(I assume it works for you in Chrome, as you may have "Montserrat" installed locally).

To ensure the font is loaded, you could load it via js FontFace() method.

Working example

const canvas = document.querySelector("canvas");
const context = canvas.getContext("2d");
context.width = document.body.clientWidth;
context.height = document.body.clientHeight;

let fontUrl =  "https://fonts.gstatic.com/s/montserrat/v24/JTUFjIg1_i6t8kCHKm459Wx7xQYXK0vOoz6jqw16WXh0pg.woff2";
let fontFamily = "Montserrat";
let fontOptions = {
  weight: 900,
  style: "italic"
};
loadFonts(fontFamily, fontUrl, fontOptions);

async function loadFonts(fontFamily, fontUrl, fontOptions) {
  const font = new FontFace(fontFamily, `url(${fontUrl})`);
  font.weight = fontOptions.weight ? fontOptions.weight : 400;
  font.style = fontOptions.style ? fontOptions.style : "normal";
  // wait for font to be loaded
  await font.load();
  document.fonts.add(font);
  // apply font styles to canvas
  canvas.classList.add("fonts-loaded");
  canvas.setAttribute(
    "style",
    `font-family:${fontFamily}; font-weight:${fontOptions.weight}; font-style:${fontOptions.style}`
  );

  drawText();
}

function drawText() {
  context.font = "48px Montserrat";
  context.fontWeight = 900;
  context.fontStyle = "italic";
  context.fillStyle = "red";
  context.textAlign = "center";
  context.textBaseline = "middle";
  context.fillText("Hamburg", 150, 50);
}
canvas {
  height: 50vh;
  border: 1px solid red
}

.fonts-loaded {
  border: 1px solid green;
}
<canvas class="game" />

  1. We're loading the font file in an async function
    (just open the google font css (e.g https://fonts.googleapis.com/css?family=Montserrat:900i) to get the actual font file url)
  2. Once the font is loaded we're applying the desired font style properties to the canvas element by setting an inline style (you could also use a class)
  3. Now we can draw the text on canvas

进口字体在Chrome,但不使用Safari

野の 2025-02-04 03:30:29

如果您在Python&gt; = 3.8上,请使用。还适用于日期时间。

# 11. May 2022 is a Wednsesday in the 19h week
>>> date.fromisocalendar(2022, 19, 3)
datetime.date(2022, 5, 11)

作为新专栏:

df['date'] = df[['year', 'week_number']].apply(lambda args: date.fromisocalendar(args[0], args[1], 1), axis=1)

If you are on Python >= 3.8, use datetime.date.fromisocalendar. Also works for datetime.

# 11. May 2022 is a Wednsesday in the 19h week
>>> date.fromisocalendar(2022, 19, 3)
datetime.date(2022, 5, 11)

As new Column:

df['date'] = df[['year', 'week_number']].apply(lambda args: date.fromisocalendar(args[0], args[1], 1), axis=1)

在熊猫中将eary_week转换为dateTime的有效方法

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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