cost 192 ms
使用 Python 中的类型模块为具有多个返回类型和条件的函数创建泛型类型提示的正确方法是什么? - What is the correct way to create a generic type hint for functions with multiple return types and conditions using the typing module in Python?

在使用pyright工具进行类型检查时,我遇到了以下问题。 (Python 3.11,版权 1.1.310) 我的代码:class TypeCast(str, enum.Enum): STRING = str FLOAT = float def cast_int_to_str( ...

连接到 PostgreSQL 时没有属性“执行”错误 - No attribute "execute" error on connecting to PostgreSQL

我在 PC1 上安装了 postgres,我正在使用 PC2 连接到数据库。 我修改了设置,以便 local.network 可以访问 PC1 上的 postgres。 在 PC2 上,我正在执行以下操作: 我收到错误: 在 PC1 上运行相同的代码时,我没有收到任何错误。 我只是注意到它只在从数据 ...

如何防止python3.11 TaskGroup取消所有任务 - How to prevent python3.11 TaskGroup from canceling all the tasks

我刚刚发现 Python 3.11 的新功能,如 ExceptionGroup 和 TaskGroup,我对以下 TaskGroup 行为感到困惑:如果组内的一个或多个任务失败,则所有其他正常任务将被取消,我没有机会更改该行为示例: 在上面的示例中,我无法打印“结尾 1”和“结尾 2”。 同时,拥有 ...

如何将字符串插入引号,同时将字符串输入保留在 Python 中? - How can I insert a string into quotations while keeping the string input in Python?

需要在引号中输入文本来完成最后一行,但我在引号中有一个字符串需要。 有没有办法将引号和字符串保存在新的字符串变量中? 这只是我项目中的一段代码,但我知道我没有展示的其他部分没有任何问题。 我试图使用这个脚本: 但是输出为错误,因为我上面显示的最后一行需要用引号引起来。 我还找不到解决这个问题的方法 ...

导入错误:在 python 3.11.1 中构建 exe 后无法导入“com.aspose” - ImportError: Failed to import ‘com.aspose’ after building exe in python 3.11.1

我使用 Python 的 AsposeCells 从 excel 个文件生成 PNG 图像。 首先,它适用于我的 Python 代码。 但是当我尝试使用 Pyinstaller 将我的脚本转换为 exe 文件时遇到了这个问题。 我无法为此提出解决方案。 请帮助我。下面给出了生成异常和异常的行。 ...

Python PyDash 'find' function 返回 Any 而不是传递的数据类型 - Python PyDash 'find' function returns Any instead of passed data type

在我的案例中,逻辑要复杂得多,但归结起来就是这样。 我有一个数据类实例列表。 根据该列表,我正在进行搜索。 当我直接访问实例时,属性建议和类型提示起作用。 但是当我使用 PyDash(就像 JavaScript 中的 Lodash)的“find”方法时,无论内部传递什么,它都会返回“Any”类型。 ...

我的 python 代码没有得到所需的 output - I am not getting the desired output with my python code

我是编程初学者,我正在尝试编写代码来打印数字的所有可能组合。 如果用户输入 3 位数字,程序将检查所有三位数字以找到可能的组合,但它会将所有数字显示为 output。例如,如果用户输入 12,则 output 应为 12 21,但它会显示来自10 到 99。 据我所知,一切正常,但结果并不像我预期 ...

Anaconda的基础环境如何更新到Python 3.11? 或者至少创建一个包含所有基础包的新环境? - How do you update to Python 3.11 in the base environment of Anaconda? Or at least create a new environment with all the base packages?

我正在使用最新的 Anaconda Navigator(适用于 Python 3.9),并且我知道如何在 Anaconda 中使用 Python 3.11 创建一个新环境。但是,每当我创建一个新环境时,那里几乎没有任何包。 基地有我需要的所有包,当我尝试使用 Python 11 的新环境时,我总是 ...

尽管使用 pip3 install requirements.txt 命令行成功,VSCode 仍无法从需求中导入 - VSCode Unable to import from requirement despite Command line being successful with pip3 install requirements.txt

所以我尝试运行 python 脚本来一次下载所有 Zoom 录音。 作为参考,我将链接我正在使用的 GitHub 存储库。 https://github.com/ricardorodrigues-ca/zoom-recording-downloader 我在 windows 上安装了 python ...

如何检查列表是否包含使用匹配大小写的元素? - How to check if list includes an element using match case?

我正在尝试使用匹配大小写检查单个元素是否在列表中。 我对这些新关键字不是很熟悉,所以 90% 确定我用错了它们。 无论如何,有没有办法做到这一点? 这是我的代码。 我期待它打印出“在列表中检测到你好。嗨。” 和“在列表中检测到你好,你好。”,但匹配语句似乎无法以这种方式工作。 有没有办法检查列表是 ...

Python 无法在 VScode 中工作 - 错误消息:“python”未被识别为内部或外部命令、可运行程序或批处理文件 - Python not working in VScode - Error MSG: 'python' is not recognized as an internal or external command, operable program or batch file

我看到了一个类似的问题,但解决方案没有帮助,因为他们说要重新启动。 基本上,我下载了 python 3.11,我确保将它添加到环境变量中,以便路径正确。 如果我搜索“python.exe”,现在 CMD 工作正常。 我会得到它 recgonized,但由于某种原因 VScode 不 regonize ...

使用 Python 根据日期和时间对文件夹中的文件进行排序 - Sort files in folder based on date and time with Python

我正在尝试遍历目录中的所有 json 文件和 append 他们的数据到我的字典。 似乎附加是随机的,而不是按日期和时间排序,因为文件是排序的。 有没有根据文件名循环和排序文件的方法? 我尝试了其他解决方案,例如将'time': datetime.fromtimestamp(os.path.getm ...

Pandas Python 3.11 Pivot FutureWarning:DataFrameGroupBy.sum 中 numeric_only 的默认值被取消 - Pandas Python 3.11 Pivot FutureWarning: default value of of numeric_only in DataFrameGroupBy.sum is depricated

有一个大型的文本和数字混合表,并且正在从较大的表中旋转较小的一组。 看来,当我更新到 Python 3.11 时,我现在在我的枢轴上收到了 FutureWarning。 代码运行良好但结果 FutureWarning:不推荐使用 DataFrameGroupBy.sum 中 numeric_only ...


 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM