Python强制条件

标签 python

有没有办法在 Python 中强制条件为真?我以前见过它是在 Haskell 中完成的,我想知道你是否可以用 Python 来完成它。例如:

>>> 2+2==5
True

最佳答案

好吧,你只需要把四等于五。

import ctypes

def deref(addr, typ):
    return ctypes.cast(addr, ctypes.POINTER(typ))

deref(id(4), ctypes.c_int)[6] = 5

2 + 2
#>>> 5

2 + 2 == 5
#>>> True

显然...

关于Python强制条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25748151/

相关文章:

python - 当表中有行时,选择语句返回空列表

python - 博托 [SSL : CERTIFICATE_VERIFY_FAILED] certificate verify failed while connecting to S3

python - 在 Python 中将 float 打印为整数

python - SKlearn 随机森林输入错误

python - 如何将 gRPC 服务器/客户端部署到 heroku?

python - 为什么 PANDAS 只能看到包含许多列的 csv 数据集的一列?

python:字典到字典的元组

python - 用于在 Python 中匹配具有相似 ID 字符串的两个集合的分类器

python - 如何使用 basehttpserver 保存使用 POST 发送的文件

python - sklearn的KNeighborsClassifier中如何根据最高精度选择K