字符串组之间差异的排序

发布于 2025-01-17 20:29:43 字数 579 浏览 2 评论 0原文

当我遇到一个问题时,我正在处理一条自定义错误消息: pytest.railise(错误,match = f'Error_message_part1 {set1 -set2} error_message_part2')

基本上,我不了解set1和set2之间的结果的排序如何起作用。即使我经过的文档也是如此,似乎也有订单。我正在与Python 3.9.10合作,

我有兴趣了解结果的“分类”如何工作。

Here is the simple example that highlighted the issue:

>>> a = {'a', 'b', 'c', 'd', 'e'}
>>> b = {'b', 'd'}
>>> a - b
{'e', 'a', 'c'}

>>> a = {'c', 'b', 'a', 'd', 'e'}
>>> a - b
{'e', 'a', 'c'}

>>> a = {'e', 'b', 'a', 'd', 'c'}
>>> a - b
{'e', 'a', 'c'}

I was working on a customised error message when I came across an issue using:
pytest.raises(error, match=f'error_message_part1 {set1 - set2} error_message_part2')

Basically, I don't understand how the ordering of the result between set1 and set2 works. There seems to be an ordering even though the documentation as far as I went through it says otherwise. I am working with python 3.9.10

I am interested in understanding how the 'sorting' of the result works.

Here is the simple example that highlighted the issue:

>>> a = {'a', 'b', 'c', 'd', 'e'}
>>> b = {'b', 'd'}
>>> a - b
{'e', 'a', 'c'}

>>> a = {'c', 'b', 'a', 'd', 'e'}
>>> a - b
{'e', 'a', 'c'}

>>> a = {'e', 'b', 'a', 'd', 'c'}
>>> a - b
{'e', 'a', 'c'}

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文