numpy.core._exceptions.ufunctypeyperor:ufunc' add'不包含具有签名匹配类型的循环(dtype('< u20'),dtype(' int64; int64')) - >没有皮顿

发布于 2025-02-11 12:01:53 字数 615 浏览 4 评论 0原文

每当我尝试在下面运行此代码时,我都会遇到错误:
numpy.core._exceptions.ifunctypeypeerror:ufunc'Add'不包含具有签名匹配类型(dtype('< u20'),dtype('int64'))的循环 - >没有

IM试图在名称uploaded_numbers下打开.data文件,然后覆盖以前与我拥有的新数据编号一起使用的文件。我知道阅读和写作部分在程序后面使用时起作用,并且它运行得很好。

有帮助吗?

import numpy as np
import pickle

with open(r'W:\Python\NEA Dice Project\account_number.data', 'rb') as x:
    uploaded_numbers = pickle.load(x)
    print(uploaded_numbers)

uploaded_numbers += 1

with open(r'W:\Python\NEA Dice Project\account_number.data', 'wb') as x:
    pickle.dump(uploaded_numbers, x)

Whenever I try to run this code below, I am met with the the error:
numpy.core._exceptions.UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U20'), dtype('int64')) -> None

Im trying to open a .data file under the name uploaded_numbers and then overwrite the file that it was previously on with the new data number I have. I know the reading and the writing part works as I use it later in the program and it works perfectly.

Any help?

import numpy as np
import pickle

with open(r'W:\Python\NEA Dice Project\account_number.data', 'rb') as x:
    uploaded_numbers = pickle.load(x)
    print(uploaded_numbers)

uploaded_numbers += 1

with open(r'W:\Python\NEA Dice Project\account_number.data', 'wb') as x:
    pickle.dump(uploaded_numbers, x)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

复古式 2025-02-18 12:01:53

您写道:

with open(r'W:\Python\NEA Dice Project\account_number.data', 'wb') as x:
    pickle.dump(uploaded_numbers)

我认为您可能忘记了“ X”参数。

with open(r'W:\Python\NEA Dice Project\account_number.data', 'wb') as x:
    pickle.dump(uploaded_numbers, x)

除此之外,恐怕我们没有太多帮助...
从提供的代码中,没有明确的使用Numpy,我们真的不知道您的.data文件中的内容,只有一行由您的错误触发。 ..

我希望我能够在您的问题下的评论部分中写这篇文章,但是我不允许这样做...

You wrote :

with open(r'W:\Python\NEA Dice Project\account_number.data', 'wb') as x:
    pickle.dump(uploaded_numbers)

I think you probably forgot the 'x' parameter.

with open(r'W:\Python\NEA Dice Project\account_number.data', 'wb') as x:
    pickle.dump(uploaded_numbers, x)

Aside from that, I'm afraid there isn't much help we can offer...
From the bit of code provided, there is no explicit use of numpy, we don't really know what's in your .data files, and only one line of the full trace-back triggered by your error...

I wish I was able to write this in the comment section under your question, but I am not allowed to do so...

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