寻梦旅人

文章 评论 浏览 29

寻梦旅人 2025-02-20 16:56:35

如果检查元素,您会看到Bootstrap容器和列有一些填充,而行的边距负数为负。

一个解决方案是在行上添加类 gx-0 ,该删除了列之间的排水沟

If you inspect the element, you can see that bootstrap containers and columns have some padding, while the row have some negative margins.

A solution would be to add the class gx-0 on the row, which removes the gutter between the columns

我的图像并不是div的全部宽度

寻梦旅人 2025-02-20 13:40:29

在将数据发送到查看文件之前,分配基于键值,就像

$data['data'] = $res->stations;

在视图文件中以下

value="<?php echo $data[0]->book_name;?>" 

Assign the key value based before sending the data to view file like following

$data['data'] = $res->stations;

In view file

value="<?php echo $data[0]->book_name;?>" 

如何在输入字段内绑定值?

寻梦旅人 2025-02-20 08:59:08

出现这些怪异的数字是因为计算机使用二进制(基本2)编号系统来计算目的,而我们使用小数(基本10)。

大多数分数数量不能准确地以二进制或十进制或两者兼而有之表示。结果 - 舍入(但精确的)数字结果。

Those weird numbers appear because computers use the binary (base 2) number system for calculation purposes, while we use decimal (base 10).

There are a majority of fractional numbers that cannot be represented precisely either in binary or in decimal or both. Result - A rounded up (but precise) number results.

浮点数学破裂了吗?

寻梦旅人 2025-02-20 08:59:08

有关于修复浮点实现问题的项目。

看看 unum&amp;例如,potit 例如,它展示了一种称为 potit (及其前任 unum )的数字类型,该数字有望提供更好的准确性,而更少的位。如果我的理解是正确的,它还可以解决问题中的问题。这是一个非常有趣的项目,背后的人是数学家, dr。约翰·古斯塔夫森(John Gustafson)

整个过程都是开源的,在C/C ++,Python,Julia和C#中具有许多实际实现( https:https:// htttps:// hastlayer。 com/算术)。

There are projects on fixing floating point implementation issues.

Take a look at Unum & Posit for example, which showcases a number type called posit (and its predecessor unum) that promises to offer better accuracy with fewer bits. If my understanding is correct, it also fixes the kind of problems in the question. It is a quite interesting project, and the person behind is a mathematician, Dr. John Gustafson.

The whole thing is open source, with many actual implementations in C/C++, Python, Julia and C# (https://hastlayer.com/arithmetics).

浮点数学破裂了吗?

寻梦旅人 2025-02-19 20:59:38

据我了解,这是一个订购问题。我认为这不是实现分类算法。在这里,我定义了 order 函数,该函数可在两个字符串上使用,并通过最后一个字符订购它们。将其应用于3次以排序3元素列表。

def order(a, b):
    return (b, a) if a[-1] > b[-1] else (a, b)
    
list1 = ["aaditya-2", "rahul-9", "shubhangi-4"]
a, b, c = list1

a, b = order(a, b)
a, c = order(a, c)
b, c = order(b, c)

list1 = [a, b, c] # ["aaditya-2", "shubhangi-4", "rahul-9"]

对于反向排序,只需在 orde> order 函数中使用&lt;

As I understand it, it's a question of ordering. I don't think this is about implementing a sorting algorithm. Here I define a order function that works on two strings and orders them by last character. This is applied 3 times to sort 3-element list.

def order(a, b):
    return (b, a) if a[-1] > b[-1] else (a, b)
    
list1 = ["aaditya-2", "rahul-9", "shubhangi-4"]
a, b, c = list1

a, b = order(a, b)
a, c = order(a, c)
b, c = order(b, c)

list1 = [a, b, c] # ["aaditya-2", "shubhangi-4", "rahul-9"]

For reverse sort, just use < in the order function.

在Python中列出问题以对字符串列表进行排序,而无需使用排序或排序函数

寻梦旅人 2025-02-19 19:41:17

如果一切正常,那么您能做的就是在HTML

<input type="submit" class="btn btn-primary" id="cart-btn" value="add to cart">

脚本中使用OnClick:

 $(document).ready(function(){
   function addToCart(){
   //function definition
 }
  $("#cart-btn").click(addToCart);
 });

In the case of everything is okay then what you can do is insted of onclick in html

<input type="submit" class="btn btn-primary" id="cart-btn" value="add to cart">

Script:

 $(document).ready(function(){
   function addToCart(){
   //function definition
 }
  $("#cart-btn").click(addToCart);
 });

未接收参考:AddTocart未定义JavaScript

寻梦旅人 2025-02-19 03:53:11

我的问题是如何处理这种情况?

由于 MessageHandler 不会(无法(无法)等待该工具包,因此它在调用等待... 时返回。

您可以尝试这样的尝试:

WeakReferenceMessenger.Default.Register<ContinueCallbackAnsweringRequestMessage>(
    this, (r, m) => m.Reply(ShowDialogAndWaitForResult()));

... showdialogandwaitforresult()是一种自定义 async 方法,它返回 task&lt; t&gt; ,调用对话框的ShowAsync()等待结果。

另一个选项是实现您自己的阻止(非ASYNC)对话框。或考虑另一种不涉及使者的解决方案。

My question is how to handle this situation?

Since the MessageHandler won't (can't) be awaited by the toolkit, it returns when you call await ....

You could try something like this:

WeakReferenceMessenger.Default.Register<ContinueCallbackAnsweringRequestMessage>(
    this, (r, m) => m.Reply(ShowDialogAndWaitForResult()));

...where ShowDialogAndWaitForResult() is a custom async method that returns a Task<T>, calls the ShowAsync() of the dialog and wait for the result.

Another option is implement your own blocking (non-async) dialog. Or consider another solution which don't involve a messenger.

UWP CommunityToolkit Messenger Async处理程序

寻梦旅人 2025-02-19 00:27:16

因此,我像这样重现了您的数据

data = [["TX", "TX"], ["DALLAS", "DALLAS"], [1, 1], ["CARP", "BLAY"], [0,0], [5,15]]
df = pd.DataFrame(data).T
df.columns=["STATE", "CITY", "TAX_C", "MATERIAL", "IG", "LIMIT"]

,我认为第一步是更深入地了解如何从数据框架中获取字典,

for key, value in df.to_dict(orient="index").items():
    print(value)

如果

{'STATE': 'TX', 'CITY': 'DALLAS', 'TAX_C': 1, 'MATERIAL': 'CARP', 'IG': 0, 'LIMIT': 5}
{'STATE': 'TX', 'CITY': 'DALLAS', 'TAX_C': 1, 'MATERIAL': 'BLAY', 'IG': 0, 'LIMIT': 15}

我们更深入地,您可以循环浏览它,并附加列表,这样

results = []
for key, value in df.to_dict(orient="index").items():
    row = list(value.items())
    for nr in range((len(value)-1)):
        results.append([list(row[nr]), list(row[nr+1])])

收益

[[['STATE', 'TX'], ['CITY', 'DALLAS']],
 [['CITY', 'DALLAS'], ['TAX_C', 1]],
 [['TAX_C', 1], ['MATERIAL', 'CARP']],
 [['MATERIAL', 'CARP'], ['IG', 0]],
 [['IG', 0], ['LIMIT', 5]],
 [['STATE', 'TX'], ['CITY', 'DALLAS']],
 [['CITY', 'DALLAS'], ['TAX_C', 1]],
 [['TAX_C', 1], ['MATERIAL', 'BLAY']],
 [['MATERIAL', 'BLAY'], ['IG', 0]],
 [['IG', 0], ['LIMIT', 15]]]

的 请注意,您在Python中无法描述。某物是列表或词典。列表仅与逗号相隔。

我希望这会有所帮助:)

So I reproduced your data like so

data = [["TX", "TX"], ["DALLAS", "DALLAS"], [1, 1], ["CARP", "BLAY"], [0,0], [5,15]]
df = pd.DataFrame(data).T
df.columns=["STATE", "CITY", "TAX_C", "MATERIAL", "IG", "LIMIT"]

And I think the first step is to go a little deeper into how you can get dictionary out of the dataframe

for key, value in df.to_dict(orient="index").items():
    print(value)

Which yields

{'STATE': 'TX', 'CITY': 'DALLAS', 'TAX_C': 1, 'MATERIAL': 'CARP', 'IG': 0, 'LIMIT': 5}
{'STATE': 'TX', 'CITY': 'DALLAS', 'TAX_C': 1, 'MATERIAL': 'BLAY', 'IG': 0, 'LIMIT': 15}

If we go a little deeper you can loop over it and append a list like so

results = []
for key, value in df.to_dict(orient="index").items():
    row = list(value.items())
    for nr in range((len(value)-1)):
        results.append([list(row[nr]), list(row[nr+1])])

yielding

[[['STATE', 'TX'], ['CITY', 'DALLAS']],
 [['CITY', 'DALLAS'], ['TAX_C', 1]],
 [['TAX_C', 1], ['MATERIAL', 'CARP']],
 [['MATERIAL', 'CARP'], ['IG', 0]],
 [['IG', 0], ['LIMIT', 5]],
 [['STATE', 'TX'], ['CITY', 'DALLAS']],
 [['CITY', 'DALLAS'], ['TAX_C', 1]],
 [['TAX_C', 1], ['MATERIAL', 'BLAY']],
 [['MATERIAL', 'BLAY'], ['IG', 0]],
 [['IG', 0], ['LIMIT', 15]]]

Please note that you description is not possible in Python. Something is a list or a dictionary. A list is separated with comma's only.

I hope this helps :)

列表列名称ITERTOOLS

寻梦旅人 2025-02-18 08:45:39

就我个人而言,我处理与此库中Swift中的日期相关的所有内容 swiftdate 。太好了。我为您留下一个例子,说明这种事情有多简单。

import SwiftDate
func workingWithDate() {
    let inputFormat = "MM/dd/yyyy hh:mma"
    let outputFormat = "dd MMM yyyy, hh:mma"
    let dateStr = "06/28/2022 06:55PM"
    guard let dateFromString = dateStr.toDate(inputFormat, region: Region.ISO) else { return }
        
    print(dateFromString)
    print("Output date: \(dateFromString.toFormat(outputFormat, locale: nil))")
}

输出是:

{abs_date='2022-06-28T18:55:00Z', rep_date='2022-06-28T18:55:00Z',
region={calendar='gregorian', timezone='GMT', locale='en_US_POSIX'}
Output date: 28 Jun 2022, 06:55PM

要理解的主要内容是,您要解析的字符串以ISO格式不包含任何区域信息,因此,如果您尝试使用UTC/GMT等进行解析,我不认为您将获得正确的价值。例如,如果您使用UTC(不包括AM/PM)进行解析,则它可以使用,但是如果您在输入格式中包含“ A”,并且在日期字符串中添加AM或PM,则将无法解析它。

Personally, I handle everything related to dates in Swift with this library SwiftDate. It's just great. I leave you an example of how simple this kind of thing is.

import SwiftDate
func workingWithDate() {
    let inputFormat = "MM/dd/yyyy hh:mma"
    let outputFormat = "dd MMM yyyy, hh:mma"
    let dateStr = "06/28/2022 06:55PM"
    guard let dateFromString = dateStr.toDate(inputFormat, region: Region.ISO) else { return }
        
    print(dateFromString)
    print("Output date: \(dateFromString.toFormat(outputFormat, locale: nil))")
}

The output is:

{abs_date='2022-06-28T18:55:00Z', rep_date='2022-06-28T18:55:00Z',
region={calendar='gregorian', timezone='GMT', locale='en_US_POSIX'}
Output date: 28 Jun 2022, 06:55PM

The main thing to understand is that the string you are trying to parse is in ISO format since it doesn't contain any zone information and therefore if you tried to parse it with UTC/GMT etc, I don't think you would get the correct value. For example if you parse using UTC without including AM/PM it works, but if you include 'a' in the input format and AM or PM in the date string it won't be able to parse it.

dateformatter显示不正确的时间

寻梦旅人 2025-02-18 02:03:00

您的颜色是 color =#...

有一个的时刻,它被认为是评论(按照您的代码),这就是为什么您有无效的语法错误。

解决方案:

将相同的内容放在字符串( color ='#00ff00')或使用 0x 而不是 color = 0x00ff00)

Your color was color=#....

The moment there is a #, it is considered to be a comment (as per your code) and that's why you have an invalid syntax error.

Solution:

Put the same within a String (color='#00ff00') or use 0x instead of # (color=0x00ff00)

我在discord.py中制作一个不符合的机器

寻梦旅人 2025-02-16 15:14:47

通过更改React App.json文件中的slug属性来解决问题。我从骆驼盒变成了所有较低的表壳。

在此之后,似乎永久性的错误已经消失。我已经能够在小型示例应用程序中复制错误。我不明白为什么这会导致这些错误。

The problem seems to be resolved by changing the slug attribute in the react app.json file. I changed the slug from being a camel case to an all lower case slug.

After this the error has gone away for what seems permanent. I've been able to replicate the error in small sample apps. I don't understand why this causes these errors.

导入Amplify引发错误“ NULL不是对象(评估&#x27; keys.filter)”在React Native应用中

寻梦旅人 2025-02-16 14:53:55
div.style.background = `url("${moviesToDisplay[each]['cover']}")`;

要将图像设置为背景,请设置 backgroundImage 背景属性。

另外,您将需要使用字符串插值,否则它将将背景图像设置为字符串。

另外, url()拿一个字符串,这就是为什么“” 需要。

div.style.background = `url("${moviesToDisplay[each]['cover']}")`;

To set image as background, either set backgroundImage or background property.

Also, you will need to use string interpolation else it will set the background image to whatever the string is.

Also, url() takes a string, that's why "" are required.

尝试通过JavaScript添加背景颜色到HTML元素

寻梦旅人 2025-02-16 11:46:30

另一种简单的方法是创建一个包装类实例的对象(例如Call ClassRefector )。然后在其上定义一种方法以返回常数字段的值。

例如:

import org.springframework.util.ReflectionUtils;

public class ClassReflector {

    private Class<?> clazz;

    public ClassReflector(String className) throws Exception {
        this.clazz = Class.forName(className);
    }

    public String getFieldVal(String fieldName) throws Exception {
        return (String) ReflectionUtils.getField(clazz.getField(fieldName), null);
    }

}

然后在XML中,使用此方法获取不同常数字段的值。

<bean id="cf" class="com.myapp.longname.verylong.ClassReflector">
    <constructor-arg value="com.myapp.longname.verylong.WelcomeController" />
</bean>


<util:list id="myFractions" value-type="java.lang.String">
    <value>#{cf.getFieldVal('RED_FRACTION')}</value>
    <value>#{cf.getFieldVal('BLUE_FRACTION')}</value>
    <value>#{cf.getFieldVal('GREEN_FRACTION')}</value>
</util:list>

Another simpler way is to create an object that wrap a class instance (e.g call ClassReflector). Then define a method on it to return the value of the constant field.

For example :

import org.springframework.util.ReflectionUtils;

public class ClassReflector {

    private Class<?> clazz;

    public ClassReflector(String className) throws Exception {
        this.clazz = Class.forName(className);
    }

    public String getFieldVal(String fieldName) throws Exception {
        return (String) ReflectionUtils.getField(clazz.getField(fieldName), null);
    }

}

Then in the XML, use this method to get the value of different constant fields.

<bean id="cf" class="com.myapp.longname.verylong.ClassReflector">
    <constructor-arg value="com.myapp.longname.verylong.WelcomeController" />
</bean>


<util:list id="myFractions" value-type="java.lang.String">
    <value>#{cf.getFieldVal('RED_FRACTION')}</value>
    <value>#{cf.getFieldVal('BLUE_FRACTION')}</value>
    <value>#{cf.getFieldVal('GREEN_FRACTION')}</value>
</util:list>

仅在beans.xml中定义其他占位符/财产

寻梦旅人 2025-02-16 06:58:01

创建一些数据,我们有两个数据范围:

import pandas as pd
import numpy as np

rng = np.random.default_rng(seed=5)
df1 = pd.DataFrame(data=rng.integers(0, 5, size=(5, 2)))
df2 = pd.DataFrame(data=rng.integers(0, 5, size=(5, 2)))
# df1
   a  b
0  3  4
1  0  4
2  2  2
3  3  1
4  4  0

# df2
   a  b
0  1  1
1  2  2
2  0  0
3  0  0
4  0  4

我们可以使用 pandas.merge 结合相等的行。而且我们可以使用其 indosator = true 功能来标记仅从左侧(以及适用时右)的行。由于我们只需要那些独特的左侧的人,因此我们可以使用 How =“ left” 合并才能提高效率。

dfm = pd.merge(df1, df2, on=list(df1.columns), how="left", indicator=True)
# dfm

    a   b   _merge
0   3   4   left_only
1   0   4   both
2   2   2   both
3   3   1   left_only
4   4   0   left_only

太好了,所以最终结果是使用合并
但是,仅保留具有 left_only 的指示器的人:

(dfm.loc[dfm._merge == 'left_only']
    .drop(columns=['_merge']))
    a   b
0   3   4
3   3   1
4   4   0

如果,则需要通过列的子集进行重复地进行重复。在这种情况下,我会这样进行合并,重复该子集,以免从左侧和右侧获得重复版本的其他列。

pd.merge(df1,df2 [subset],on = subset,how =“ left”,indistor = true)>

Creating some data, we have two dataframes:

import pandas as pd
import numpy as np

rng = np.random.default_rng(seed=5)
df1 = pd.DataFrame(data=rng.integers(0, 5, size=(5, 2)))
df2 = pd.DataFrame(data=rng.integers(0, 5, size=(5, 2)))
# df1
   a  b
0  3  4
1  0  4
2  2  2
3  3  1
4  4  0

# df2
   a  b
0  1  1
1  2  2
2  0  0
3  0  0
4  0  4

We can use pandas.merge to combine equal rows. And we can use its indicator=True feature to mark those rows that are only from the left (and right, when applicable). Since we only need those that are unique to left, we can merge using how="left" to be more efficient.

dfm = pd.merge(df1, df2, on=list(df1.columns), how="left", indicator=True)
# dfm

    a   b   _merge
0   3   4   left_only
1   0   4   both
2   2   2   both
3   3   1   left_only
4   4   0   left_only

Great, so then the final result is using the merge
but only keeping those that have an indicator of left_only:

(dfm.loc[dfm._merge == 'left_only']
    .drop(columns=['_merge']))
    a   b
0   3   4
3   3   1
4   4   0

If you'd want to deduplicate by a subset of the columns, that should be possible. In that case I would do the merge it like this, repeating the subset so that we don't get other columns in duplicate versions from the left and right side.

pd.merge(df1, df2[subset], on=subset, how="left", indicator=True)

合并数据框并仅提取其他数据框中不存在的数据框的行

寻梦旅人 2025-02-16 05:53:07

Description

这是一个示例示例脚本,可从Google表格获取图表并放在Google文档中。我用作“ Chart1”段落的地方持有人。

电子表格

​noreferrer“> ”

doc(efter)

code.gs

function testChart() {
  try {
    let charts = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Chart").getCharts();
    // In this case there is only 1
    let chart = charts[0];
    chart = chart.getAs("image/png");
    let doc = DocumentApp.openById("1A........................ds");
    let body = doc.getBody();
    let paras = body.getParagraphs();
    for( let i=0; i<paras.length; i++ ) {
      let para = paras[i];
      let text = para.getText();
      if( text === "Chart1" ) {
        para.addPositionedImage(chart);
      }
    }
  }
  catch(err) {
    console.log(err);
  }
}

参考

Description

Here is a sample example script to get a chart from Google Sheet and place in a Google Doc. I use as a place holder the paragraph "Chart1".

Spreadsheet

enter image description here

Doc (Before)

enter image description here

Doc (After)

enter image description here

Code.gs

function testChart() {
  try {
    let charts = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Chart").getCharts();
    // In this case there is only 1
    let chart = charts[0];
    chart = chart.getAs("image/png");
    let doc = DocumentApp.openById("1A........................ds");
    let body = doc.getBody();
    let paras = body.getParagraphs();
    for( let i=0; i<paras.length; i++ ) {
      let para = paras[i];
      let text = para.getText();
      if( text === "Chart1" ) {
        para.addPositionedImage(chart);
      }
    }
  }
  catch(err) {
    console.log(err);
  }
}

Reference

将多个图表从床单复制到文档

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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