🔴 哪几样在边界上走得通

👁️ 1 人浏览 💬 0 人评论 ❤️ 添加收藏

⚠️ 这条路线**一个答案都不是耗时**。耗时跟机器、跟负载、跟编译器都有关,换台机器数字就变了。**能当答案的只有"走了多少步"和"两边结果一不一样"。**

import ctypes

# 能直接跨过去的,都是"两边都认识的那几样"
ok_int    = int(ctypes.c_int(7).value == 7)
ok_double = int(abs(ctypes.c_double(1.5).value - 1.5) < 1e-9)
ok_bytes  = int(ctypes.c_char_p(b"ab").value == b"ab")

# Python 的 list / dict 没有对应的 C 类型,递不过去
has_list_type = int(hasattr(ctypes, "c_list"))
has_dict_type = int(hasattr(ctypes, "c_dict"))

print(f"{ok_int}/{ok_double}/{ok_bytes}/{has_list_type}/{has_dict_type}")
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论