甜点

文章 评论 浏览 28

甜点 2025-02-20 08:59:08

No, not broken, but most decimal fractions must be approximated

Summary

Floating point arithmetic is exact, unfortunately, it doesn't match up well with our usual base-10 number representation ,因此,事实证明,我们经常给出它的输入,这些输入与我们所写的内容相比有些偏离。

即使是简单的数字,例如0.01、0.02、0.03、0.04 ... 0.24也不能像二进制分数一样表示。如果您计数0.01,.02,.03 ...,直到到达0.25之前,您将获得第一个分数,可以在base 2 中表示。如果您尝试使用FP,则您的0.01将略有关闭,因此,将其中25个添加到精确的0.25的唯一方法是需要一系列涉及后卫碎片和圆形的因果关系。很难预测,所以我们举起双手说“ FP是不精确的”,,但这并不是真的。

We constantly give the FP hardware something that seems simple in base 10 but is a repeating fraction in base 2.

How did this happen?

When we write in decimal, every fraction (specifically, every terminating十进制)是形式的合理数字

       
a / (2n x 5m)

In binary, we only get the 2n term, that is:

           a / 2n

So in decimal, we can't represent 1/3.因为基本10包括2作为主要因素,所以我们可以写入二进制分数 的每个数字也可以写为基本10分数。但是,我们几乎没有写任何作为基础 10 的分数在二进制中表示。在0.01、0.02、0.03 ... 0.99的范围内,只能以我们的FP格式表示三个数字:0.25、0.50和0.75,因为它们是1/4、1/2,和3/4,仅使用2 n 术语的所有数字。

在基本 10 中,我们不能表示 1 / 3 。但是在二进制中,我们不能做 1 / 10 1 / 3

因此,尽管每个二元分数都可以用小数为小数,但相反是不正确的。实际上,大多数小数分数在二进制中重复。

Dealing with it

Developers are usually instructed to do < Epsilon 比较,更好的建议可能是圆形的积分值(在C库中:round()和roundf(),即以FP格式保持),然后进行比较。四舍五入到特定的小数分数长度可以解决大多数输出​​问题。

同样,关于实际数字迫切问题(FP是在早期,昂贵的计算机上发明的问题),宇宙的物理常数和所有其他测量值仅是相对较少的重要数字知道的,因此整个问题空间无论如何是“不精确的”。在这种应用中,FP“准确性”不是问题。

当人们试图将FP用于豆类计数时,整个问题确实会产生。它确实为此起作用,但是只有当您坚持积分价值时,哪种使用它的要点。 This is why we have all those decimal fraction software libraries.

I love the Pizza answer by Chris ,因为它描述了实际问题,而不仅仅是关于“不准确性”的通常手动挥舞。如果FP简单地“不准确”,那么我们可以修复,并且几十年前就可以做到这一点。我们没有的原因是因为FP格式紧凑且快速,这是处理大量数字的最佳方法。此外,这是空间年龄和军备竞赛的遗产,也是使用小型内存系统来解决非常缓慢的计算机来解决大问题的遗产。 (有时是1位存储的单个磁芯,但这是又story.)

Conclusion

If you are just counting beans at a bank, software solutions that use decimal string representations in the first place work perfectly well.但是,您不能这样做量子染色体动力学或空气动力学。

No, not broken, but most decimal fractions must be approximated

Summary

Floating point arithmetic is exact, unfortunately, it doesn't match up well with our usual base-10 number representation, so it turns out we are often giving it input that is slightly off from what we wrote.

Even simple numbers like 0.01, 0.02, 0.03, 0.04 ... 0.24 are not representable exactly as binary fractions. If you count up 0.01, .02, .03 ..., not until you get to 0.25 will you get the first fraction representable in base2. If you tried that using FP, your 0.01 would have been slightly off, so the only way to add 25 of them up to a nice exact 0.25 would have required a long chain of causality involving guard bits and rounding. It's hard to predict so we throw up our hands and say "FP is inexact", but that's not really true.

We constantly give the FP hardware something that seems simple in base 10 but is a repeating fraction in base 2.

How did this happen?

When we write in decimal, every fraction (specifically, every terminating decimal) is a rational number of the form

a / (2n x 5m)

In binary, we only get the 2n term, that is:

           a / 2n

So in decimal, we can't represent 1/3. Because base 10 includes 2 as a prime factor, every number we can write as a binary fraction also can be written as a base 10 fraction. However, hardly anything we write as a base10 fraction is representable in binary. In the range from 0.01, 0.02, 0.03 ... 0.99, only three numbers can be represented in our FP format: 0.25, 0.50, and 0.75, because they are 1/4, 1/2, and 3/4, all numbers with a prime factor using only the 2n term.

In base10 we can't represent 1/3. But in binary, we can't do 1/10 or 1/3.

So while every binary fraction can be written in decimal, the reverse is not true. And in fact most decimal fractions repeat in binary.

Dealing with it

Developers are usually instructed to do < epsilon comparisons, better advice might be to round to integral values (in the C library: round() and roundf(), i.e., stay in the FP format) and then compare. Rounding to a specific decimal fraction length solves most problems with output.

Also, on real number-crunching problems (the problems that FP was invented for on early, frightfully expensive computers) the physical constants of the universe and all other measurements are only known to a relatively small number of significant figures, so the entire problem space was "inexact" anyway. FP "accuracy" isn't a problem in this kind of application.

The whole issue really arises when people try to use FP for bean counting. It does work for that, but only if you stick to integral values, which kind of defeats the point of using it. This is why we have all those decimal fraction software libraries.

I love the Pizza answer by Chris, because it describes the actual problem, not just the usual handwaving about "inaccuracy". If FP were simply "inaccurate", we could fix that and would have done it decades ago. The reason we haven't is because the FP format is compact and fast and it's the best way to crunch a lot of numbers. Also, it's a legacy from the space age and arms race and early attempts to solve big problems with very slow computers using small memory systems. (Sometimes, individual magnetic cores for 1-bit storage, but that's another story.)

Conclusion

If you are just counting beans at a bank, software solutions that use decimal string representations in the first place work perfectly well. But you can't do quantum chromodynamics or aerodynamics that way.

浮点数学破裂了吗?

甜点 2025-02-20 05:37:17

如评论中所建议的,了解Ajax。这是一个示例代码:

let newGameData = {
  score: title,
  jumps: content,
};

$.post("/", newGameData, function(result) {
  console.log(result)
})

在服务器端,不要重定向,而是res.send(结果)。

As suggested in the comments, learn about Ajax. This is a sample code:

let newGameData = {
  score: title,
  jumps: content,
};

$.post("/", newGameData, function(result) {
  console.log(result)
})

and on the server side, don't redirect, but rather res.send(result).

从JavaScript文件而不是HTML/CSS检索可变值

甜点 2025-02-20 01:43:13

由于人们在链接错误错误时似乎是针对这个问题的,所以我将在此处添加此问题。

使用GCC 5.2.0的链接器错误的一个可能原因是,默认情况下,选择了一个新的libstdc ++库ABI。

如果您获得了有关不确定的引用到涉及std :: __ cxx11命名空间或标签[abi:cxx11]的符号的链接错误,则可能表明您试图将链接到与不同值的对象文件中链接在一起对于_glibcxx_use_cxx11_abi宏。当链接到使用较旧版本的GCC编辑的第三方库时,通常会发生这种情况。如果第三方库无法与新的ABI进行重建,则您需要将代码与旧的ABI重新编译。

因此,如果在5.1.0之后切换到GCC时突然遇到链接器错误,这将是一件值得一看的事情。

Since people seem to be directed to this question when it comes to linker errors I am going to add this here.

One possible reason for linker errors with GCC 5.2.0 is that a new libstdc++ library ABI is now chosen by default.

If you get linker errors about undefined references to symbols that involve types in the std::__cxx11 namespace or the tag [abi:cxx11] then it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking to a third-party library that was compiled with an older version of GCC. If the third-party library cannot be rebuilt with the new ABI then you will need to recompile your code with the old ABI.

So if you suddenly get linker errors when switching to a GCC after 5.1.0 this would be a thing to check out.

什么是未定义的参考/未解决的外部符号错误,我该如何修复?

甜点 2025-02-20 01:37:07

我认为,如果您在进一步的用例中分开材料应用上下文,那会更好。还可以尝试使用 Align 窗口小部件进行动态放置。

@override
Widget build(BuildContext context) {
  return Scaffold(
    backgroundColor: const Color(0xffF24004),
    body: LayoutBuilder(
      builder: (context, constraints) => Stack(
        children: [
          Align(
            alignment: const Alignment(0, -.75),
            child: Container(
              width: constraints.maxWidth * .8, //image size
              height: constraints.maxWidth * .8,
              color: Colors.green,
            ),
            // Image.asset(
            //   "lib/img/pomodoro.png",
            //   width: 250,
            //   height: 250,
            // ),
          ),
          Align(
            alignment: Alignment.bottomCenter,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                ...List.generate(
                  3,
                  (index) => Container(
                    width: constraints.maxWidth,
                    height: constraints.maxHeight * .1,
                    color: index.isEven ? Colors.deepPurple : Colors.amber,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    ),
  );
}


有关 stack

I think it would be better if you separate material-app context in further use case. Also try using Align widget for dynamic placement.

@override
Widget build(BuildContext context) {
  return Scaffold(
    backgroundColor: const Color(0xffF24004),
    body: LayoutBuilder(
      builder: (context, constraints) => Stack(
        children: [
          Align(
            alignment: const Alignment(0, -.75),
            child: Container(
              width: constraints.maxWidth * .8, //image size
              height: constraints.maxWidth * .8,
              color: Colors.green,
            ),
            // Image.asset(
            //   "lib/img/pomodoro.png",
            //   width: 250,
            //   height: 250,
            // ),
          ),
          Align(
            alignment: Alignment.bottomCenter,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                ...List.generate(
                  3,
                  (index) => Container(
                    width: constraints.maxWidth,
                    height: constraints.maxHeight * .1,
                    color: index.isEven ? Colors.deepPurple : Colors.amber,
                  ),
                )
              ],
            ),
          )
        ],
      ),
    ),
  );
}

enter image description here
More about Stack

如何使用图像和文字在颤音中实现3列布局?

甜点 2025-02-19 19:25:53

我对Python口译员的内部运作一无所知(而且我也不是编译器和口译员的专家),所以如果我提出任何不友善或不可能的事情,请不要怪我。

只要Python对象是可变的,我认为在设计默认参数的内容时应考虑这一点。
当您实例化列表时:

a = []

您希望获得 a 的列表。

a = []

def x(a=[]):

为什么在实例化功能定义的新列表中,而不是调用中的新列表中的 ?
就像您在问“如果用户不提供参数,那么 bactantiate 一个新列表,并将其像呼叫者产生一样使用”。
我认为这是模棱两可的:

def x(a=datetime.datetime.now()):

用户,您是否希望 a 默认到与定义或执行 x 相对应的日期时间?
在这种情况下,就像在上一篇中一样,我将保持相同的行为,就像默认参数“分配”是该函数的第一个指令( dateTime.now() on Function Invocation) 。
另一方面,如果用户想要他可以写的定义时间映射:

b = datetime.datetime.now()
def x(a=b):

我知道,我知道:这是一个封闭。另外,Python可能会提供一个关键字来强制定义时间绑定:

def x(static a=b):

I know nothing about the Python interpreter inner workings (and I'm not an expert in compilers and interpreters either) so don't blame me if I propose anything unsensible or impossible.

Provided that python objects are mutable I think that this should be taken into account when designing the default arguments stuff.
When you instantiate a list:

a = []

you expect to get a new list referenced by a.

Why should the a=[] in

def x(a=[]):

instantiate a new list on function definition and not on invocation?
It's just like you're asking "if the user doesn't provide the argument then instantiate a new list and use it as if it was produced by the caller".
I think this is ambiguous instead:

def x(a=datetime.datetime.now()):

user, do you want a to default to the datetime corresponding to when you're defining or executing x?
In this case, as in the previous one, I'll keep the same behaviour as if the default argument "assignment" was the first instruction of the function (datetime.now() called on function invocation).
On the other hand, if the user wanted the definition-time mapping he could write:

b = datetime.datetime.now()
def x(a=b):

I know, I know: that's a closure. Alternatively Python might provide a keyword to force definition-time binding:

def x(static a=b):

&quot“至少惊讶”和可变的默认论点

甜点 2025-02-19 13:27:35

错误 typeerror'nattype'对象不会出现出现,因为您试图将null值称为函数。

在行 str中(dataframe ['parsed_ts'] [i]('%y-%m-%d%h:%m:%m:%s')),零件 dataframe [ 'parsed_ts'] [i] 正在返回零值,您正在尝试访问其属性('%y-%m-%d%h:%m:%m:%s'),,这是错误的。如果您想更改时间戳的格式,请尝试先处理空值,然后用 datetime.strptime和/或datetime.strftime ,根据数据集中的数据的显示方式。

The Error TypeError 'NaTType' object is not callable appears because you are trying to call a null value as a function.

In the line str(dataFrame['parsed_ts'][i]('%Y-%m-%d %H:%M:%S')), the part dataFrame['parsed_ts'][i] is returning a null value and you are trying to access its property ('%Y-%m-%d %H:%M:%S'), which is wrong. If you want to transform the format of your timestamps, try handling the null values first and then wrangling the timestamps with datetime.strptime and/or datetime.strftime, according to how the data is presented in your dataset.

发生了例外:typeError&#x27; nattype&#x27;对象不可呼应

甜点 2025-02-18 22:36:29

如果我正确理解,则需要在 MAP 中返回 vec

fn main() {
    let mut vec_of_strings = vec![
        vec!["a1", "b2", "c3"], 
        vec!["d1", "e2", "f3"], 
        vec!["g1", "h2", "i3"]
    ];
    println!("{:?}", vec_of_strings);
    
    let vec_of_strings: Vec<Vec<&str>> = vec_of_strings.iter_mut().map(|x| {x.push("something"); x.clone()}).collect();
    println!("{:?}", vec_of_strings);
}

If I understand correctly, You need to return a vec in map.

fn main() {
    let mut vec_of_strings = vec![
        vec!["a1", "b2", "c3"], 
        vec!["d1", "e2", "f3"], 
        vec!["g1", "h2", "i3"]
    ];
    println!("{:?}", vec_of_strings);
    
    let vec_of_strings: Vec<Vec<&str>> = vec_of_strings.iter_mut().map(|x| {x.push("something"); x.clone()}).collect();
    println!("{:?}", vec_of_strings);
}

Rust Playground

如何将其他元素推向Vec&lt;&amp; vec&lt; gt;&gt;?

甜点 2025-02-18 06:57:04

如果不存在,我通过将用户保存在缓存(DB)中来解决:

String username = getUsernameFromToken(token);
String userId = "my-" + username;
UserModel userModel = new InMemoryUserAdapter(session, session.getContext().getRealm(), username);
userModel.setUsername(username);
userModel.setEnabled(true);

if (session.users().getUserById(realm, userId) == null) {
    session.userCache().addUser(realm, userId, username, false, false);
}

I solved by saving the user in the cache (db) if not exist:

String username = getUsernameFromToken(token);
String userId = "my-" + username;
UserModel userModel = new InMemoryUserAdapter(session, session.getContext().getRealm(), username);
userModel.setUsername(username);
userModel.setEnabled(true);

if (session.users().getUserById(realm, userId) == null) {
    session.userCache().addUser(realm, userId, username, false, false);
}

创建KeyCloak端点以提供自定义身份验证

甜点 2025-02-18 02:35:45

阅读了 rijndaelmanaged 已被弃用, aesgcm (.net core 3.1中引入)优于 aesmanaged ,我正在尝试尝试实施 AESGCM 使用本教程和此答案。

rijndaelmanaged 已弃用,但它是一个实现类。您应该一直使用 aes.create 而不是很长一段时间,更喜欢no-argument构造函数。通常,这将为您提供优化的C/C ++版本,该版本可以利用CPU的一部分(很可能)的AES_NI指令集。使用.NET实现“托管”类,并且狗慢>

AESGCM 可以并且应该直接使用,并在密码中添加了真实性和完整性。

 使用var aes = new aesgcm(passwordbytes);
 

是的,不,那是不对的。密码不是密钥,AES在密钥上而不是密码。因此,缺少密钥(可能是IV)的部分(可能是IV)。这应该从您提到的上一个示例中复制。但是,您应该使用 int nonceize = aesgcm.noncebyize.maxsize ,因为gcm最适合96位/12个字节nonce(我想,我想给您的东西,原则上,GCM对于NONCE没有功能最大

当然,如果允许性能,则​​可以增加迭代次数。只要您应该为每个新的密文更改盐,就可以计算nonce ,就可以计算nonce。当心,如果盐和nonce 重复< / strong>重复出现,您的方案将非常失败,因此请确保使用128位 / 16字节盐。


AESGCM似乎没有迭代的手段。我应该在某个地方迭代一部分吗?如果我应该迭代,我该怎么做?

没错,但这是因为它假定是一个完全随机的密钥。如果您有密码,则必须执行PBKDF2( RFC2898DeriveBytes class insterments)或其他基于密码的键推导功能


当心AES-GCM的上限为64 GIB(减去几个字节)。

更糟糕的是,它要求您将所有明文 /密文存储在缓冲区中。从这种意义上讲,它可能不是基于文件加密的最佳选择。您也可以使用GCM加密块,但是您需要在身份验证标签上执行HMAC,以确保未重新排序单独验证的块。

iv和ciphertext上的AES-CBC + HMAC可能是另一个选择。

Having read that RijndaelManaged is deprecated and AesGcm (introduced in .NET Core 3.1) is preferred over AesManaged, I'm trying to implement AesGcm using this tutorial and this answer.

RijndaelManaged is deprecated but it is an implementation class. You should have been using Aes.Create instead for a long time, preferring the no-argument constructor. Generally this will give you the optimized C/C++ version that can utilize the AES_NI instruction set that is - very likely - part of your CPU. The "Managed" classes are implemented using .NET and are comparably dog slow.

AesGcm can and should be used directly it seems, and adds authenticity and integrity to the cipher.

using var aes = new AesGcm(passwordBytes);

Yes, no, that's not right. A password is not a key, and AES operates on keys, not passwords. So the part where the key (and possibly IV) are derived from the password is missing. This should be copied from the previous example that you mentioned. However, you should use int nonceSize = AesGcm.NonceByteSizes.MaxSize as GCM works best for a 96 bit / 12 byte nonce (which is, I suppose what that gives you, in principle GCM doesn't have a functional maximum size for the nonce).

Of course, if performance permits, you can up the number of iterations. Calculating the nonce is fine, as long as you change the salt for each new ciphertext as it should. Beware that your scheme will horribly fail if the salt and nonce do repeat, so use a 128 bit / 16 byte salt just to be sure.


AesGcm doesn't seem to have a means of iterating. Should I be iterating a part somewhere? If I should be iterating, how should I do this please?

That's correct, but that's because it assumes a fully randomized key. If you have a password, you will have to perform PBKDF2 (which the badly named Rfc2898DeriveBytes class implements) or another password based key derivation function.


Beware that AES-GCM has an upper limit of 64 GiB (minus a few bytes).

Worse, it requires you to store all the plaintext / ciphertext in a buffer. It may not be the best option for file based encryption in that sense. You can encrypt chunks with GCM as well, but then you need to e.g. perform a HMAC over the authentication tags to make sure that the separately authenticated chunks are not reordered.

AES-CBC + HMAC over IV and ciphertext could be another option.

我应该在AESGCM中使用迭代吗?

甜点 2025-02-17 16:40:14

您忘记设置 verify = false 获取文件时

urls = []
for link in soup.find_all('a'):
    file_link = link.get('href')
    if file_type in file_link:
        print(file_link)
        with open(link.text, 'wb') as file:
            response = requests.get(url + file_link, verify=False) # <-- This is where you forgot
            file.write(response.content)

You forgot to set verify=False when you get your files

urls = []
for link in soup.find_all('a'):
    file_link = link.get('href')
    if file_type in file_link:
        print(file_link)
        with open(link.text, 'wb') as file:
            response = requests.get(url + file_link, verify=False) # <-- This is where you forgot
            file.write(response.content)

Web刮擦和使用Python下载Excel文件

甜点 2025-02-17 14:09:14

un 提交 TED数据仅在创建它的会话中可见(并且,如果没有 CONDE> CONDE> CONDE> CONDE> CODER 在会话结束时将可见。泰德)。如果您看不到另一个会话(C#)的数据,请确保已在SQL客户端(TOAD)中发布了 commit 命令。

如果您已经发布了 commit ,但仍然看不到数据,请确保SQL客户端(TOAD)和C#程序都连接到同一数据库,并在查询同一用户的架构该数据库。

UnCOMMITted data is only visible within the session that created it (and will ROLLBACK at the end of the session if it has not been COMMITted). If you can't see the data from another session (C#) then make sure you have issued a COMMIT command in the SQL client (Toad).

If you have issued a COMMIT and still can't see the data then make sure that both the SQL Client (Toad) and the C# program are connecting to the same database and are querying the same user's schema of that database.

在数据库中使用ODBC驱动程序查询结果,但在C#中不填充数据库,没有错误

甜点 2025-02-17 11:02:48

感谢您提示使用另一个第三方库。
我给Epplus一个机会。

这是代码:

private void ExportWithEPPlus(string filepath)
{
    using (ExcelPackage excelPackage = new ExcelPackage())
    {
        ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1");
        try
        {
            for (int i = 0; i <= dataGridView1.RowCount - 1; ++i)
            {
                for (int j = 0; j <= dataGridView1.ColumnCount - 1; ++j)
                {
                    DataGridViewCell cell = dataGridView1[j, i];
                    worksheet.Cells[i + 1, j + 1].Value = cell.Value;
                }
            }
        catch (Exception ex) { /*somestuff*/ }
        finally
        {
            FileInfo fi = new FileInfo(@filepath);
            excelPackage.SaveAs(fi);            
        }
    }
}

就像地狱一样快。缺点是:它的记忆饿了。

Thanks for the hints to use another third-party library.
I was giving EPPLus a chance.

Here is the code:

private void ExportWithEPPlus(string filepath)
{
    using (ExcelPackage excelPackage = new ExcelPackage())
    {
        ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1");
        try
        {
            for (int i = 0; i <= dataGridView1.RowCount - 1; ++i)
            {
                for (int j = 0; j <= dataGridView1.ColumnCount - 1; ++j)
                {
                    DataGridViewCell cell = dataGridView1[j, i];
                    worksheet.Cells[i + 1, j + 1].Value = cell.Value;
                }
            }
        catch (Exception ex) { /*somestuff*/ }
        finally
        {
            FileInfo fi = new FileInfo(@filepath);
            excelPackage.SaveAs(fi);            
        }
    }
}

It's fast like hell. The drawback is: It's memory hungry.

从DataGridView创建Excel文件

甜点 2025-02-17 10:22:45

因此,最后我找到了这个问题背后的原因。当我使用Inspect看到浏览器中显示的页面代码时,我发现无论在哪里使用the_content()WordPress实际上是通过将内容插入HTML代码中的内容,为:

<section class="social-post-top">
<div class="container social-post-top-container">
<div class="social-post-top-content">
<div class="excerpt">Tincidunt tortor aliquam nulla facilisi. Enim blandit volutpat maecenas volutpat blandit. Amet volutpat consequat mauris nunc congue nisi vitae. Fames ac turpis egestas sed tempus urna et pharetra pharetra. Et netus et malesuada fames ac turpis egestas sed. Pellentesque id nibh tortor id aliquet. Venenatis lectus magna fringilla urna porttitor rhoncus dolor. Morbi tristique senectus et netus et malesuada fames ac. Interdum velit euismod in pellentesque massa placerat duis. Eget velit aliquet sagittis id consectetur purus ut faucibus. Nunc non blandit massa enim nec. Nibh mauris cursus mattis molestie a. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Lectus proin nibh            </div>
        </div>
    </div>
</section>

内容仅在哪里:

tincidunt tortor tortor aliquam nulla facilisi。 Enim Blandit Volutpat Maecenas Volutpat Blandit。 Amet Volutpat Reactat Accont Mauris Nunc会助理Nisi Vitae。 Fames Ac turpis egestas sed tempus urna et pharetra pharetra。 ET Netus等人Malesuada Fames Ac Turpis egestas sed。 Pellentesque ID nibh tortor id等级。 Venenatis lectus magna Fringilla urna Porttitor Rhoncus Dolor。 Morbi Tristique Senectus et Netus等人Malesuada Fames AC。 pellentesque massa placerat duis中的杂质euismod。 Eget Velit等分试样sagittis id Consecttur purus ut faucibus。 NUNC非Blandit Massa Enim Nec。 Nibh Mauris cursus mattis molestie a。 HAC栖息地高dandumst rhoncus est pellentesque。 lectus proin nibh

没有得到原因可能是由于某个插件或其他原因引起的,因为我没有在functions.php中使用add_filter(“ the_content”,“ the_content”,noyfuncname')将任何html添加到$ content.php中,但用于解决此问题问题,然后我将add_filter添加到functions.php as:

function bts_add_html_to_content( $content ) {
$new_content=strip_tags($content);
return $new_content;
}
add_filter( 'the_content', 'bts_add_html_to_content', 99);

因此:我使用了php的strip_tags()函数作为剥离字符串,这是$ content的主要内容。因此,这就是我解决这个问题的方式。

希望这个答案将来会帮助别人

So finally I found the reason behind this issue. When I saw the code of page displayed in the browser using inspect then I found that wherever I was using the_content() WordPress was actually inserting content by enclosing it within HTML code as:

<section class="social-post-top">
<div class="container social-post-top-container">
<div class="social-post-top-content">
<div class="excerpt">Tincidunt tortor aliquam nulla facilisi. Enim blandit volutpat maecenas volutpat blandit. Amet volutpat consequat mauris nunc congue nisi vitae. Fames ac turpis egestas sed tempus urna et pharetra pharetra. Et netus et malesuada fames ac turpis egestas sed. Pellentesque id nibh tortor id aliquet. Venenatis lectus magna fringilla urna porttitor rhoncus dolor. Morbi tristique senectus et netus et malesuada fames ac. Interdum velit euismod in pellentesque massa placerat duis. Eget velit aliquet sagittis id consectetur purus ut faucibus. Nunc non blandit massa enim nec. Nibh mauris cursus mattis molestie a. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Lectus proin nibh            </div>
        </div>
    </div>
</section>

where the content was only:

Tincidunt tortor aliquam nulla facilisi. Enim blandit volutpat maecenas volutpat blandit. Amet volutpat consequat mauris nunc congue nisi vitae. Fames ac turpis egestas sed tempus urna et pharetra pharetra. Et netus et malesuada fames ac turpis egestas sed. Pellentesque id nibh tortor id aliquet. Venenatis lectus magna fringilla urna porttitor rhoncus dolor. Morbi tristique senectus et netus et malesuada fames ac. Interdum velit euismod in pellentesque massa placerat duis. Eget velit aliquet sagittis id consectetur purus ut faucibus. Nunc non blandit massa enim nec. Nibh mauris cursus mattis molestie a. Hac habitasse platea dictumst vestibulum rhoncus est pellentesque. Lectus proin nibh

Did not get the reason why it occurred may be due to some plugin or some other reason as I was not adding any HTML to $content using add_filter("the_content",'anyfuncname') in functions.php but for solving this issue, I then added add_filter to functions.php as:

function bts_add_html_to_content( $content ) {
$new_content=strip_tags($content);
return $new_content;
}
add_filter( 'the_content', 'bts_add_html_to_content', 99);

So I used the strip_tags() function of PHP for stripping string which was the main content from $content. So this is how I solved this issue.

Hope this answer will help someone else in future

WordPress内容未正确显示使用the_content()

甜点 2025-02-17 00:37:23

如果要将图像保存在增强目录中。只需使用以下方式:

name = "Augmented" # As you have already used this variable
final_dir = os.path.join(os.getcwd(), name)
image_file = os.path.join(final_dir, "output.jpg")##you can change image name as you wish
cv2.imwrite(image_file, image1) ## image1 is already defined in your code

If you want to save image in augmented directory. just use this:

name = "Augmented" # As you have already used this variable
final_dir = os.path.join(os.getcwd(), name)
image_file = os.path.join(final_dir, "output.jpg")##you can change image name as you wish
cv2.imwrite(image_file, image1) ## image1 is already defined in your code

如何将图像保存在已经存在的目录中?

甜点 2025-02-16 14:32:44

如果我正确理解您的问题,请使用掩码进行过滤行,以测试NAN值

import pandas as pd
from numpy import nan as NaN
s = pd.Series([[1, 2, 3, NaN, NaN], [4, 5]])
s = s[~s.apply(lambda list1: any(pd.isna(x) for x in list1))]
print(s)

1    [4, 5]
dtype: object

If I understood your question properly, filtering rows using a mask which tests for NaN values should work

import pandas as pd
from numpy import nan as NaN
s = pd.Series([[1, 2, 3, NaN, NaN], [4, 5]])
s = s[~s.apply(lambda list1: any(pd.isna(x) for x in list1))]
print(s)

1    [4, 5]
dtype: object

如果列条目包含NAN,则丢弃行

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

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