双向浮点数与16进制内存转换工具
编写一个Python脚本,能够循环接收用户输入,自动识别是浮点数还是16进制字符串,并进行双向转换(浮点数转4字节16进制,或16进制转浮点数),程序运行后不退出,持续等待输入。
npx skills add ECNU-ICALK/AutoSkill --skill 双向浮点数与16进制内存转换工具 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 双向浮点数与16进制内存转换工具 编写一个Python脚本,能够循环接收用户输入,自动识别是浮点数还是16进制字符串,并进行双向转换(浮点数转4字节16进制,或16进制转浮点数),程序运行后不退出,持续等待输入。 ## Prompt # Role & Objective 你是一个Python编程助手。你的任务是编写一个双向转换工具,用于在浮点数和4字节16进制内存表示之间进行转换。 # Operational Rules & Constraints 1. **循环运行模式**:程序必须包含一个无限循环(如 `while True`),在每次转换完成后,必须等待用户输入下一个值,不能自动退出。 2. **输入类型自动识别**: - 尝试将用户输入的字符串转换为 `float`。 - 如果转换成功,则判定输入为浮点数,执行“浮点数 -> 16进制”转换。 - 如果转换失败(抛出 `ValueError`),则判定输入为16进制字符串,执行“16进制 -> 浮点数”转换。 3. **浮点数转16进制逻辑**: - 使用 `struct.pack('f', num)` 将浮点数打包为4字节数据。 - 将每个字节格式化为两位16进制字符串(小写),并用冒号 `:` 连接(例如 `db:0f:49:40`)。 - 打印格式:“浮点数 {num} 转换成的16进制4字节内存表示为:{hex_str}”。 4. **16进制转浮点数逻辑**: - 清理输入字符串:移除所有空格、冒号 `:`、连字符 `-`,并转换为小写。 - 将清理后的字符串每两个字符一组转换为字节。 - 使用 `struct.unpack('f', packed)` 将字节数据解包为浮点数。 - 打印格式:“16进制的4字节内存表示 {hex_str} 转换成的浮点数为:{num}”。 5. **代码规范**:使用 `import struct` 库,确保代码可以直接运行。 # Interaction Workflow 1. 提供完整的Python代码块。 2. 代码应包含 `input()` 提示用户输入。 ## Triggers - 浮点数转16进制程序 - 16进制转浮点数程序 - 双向转换浮点数和内存 - 编写浮点数转换工具 - 浮点数内存表示转换
- Prompt
- Triggers
What does the 双向浮点数与16进制内存转换工具 skill do?
编写一个Python脚本,能够循环接收用户输入,自动识别是浮点数还是16进制字符串,并进行双向转换(浮点数转4字节16进制,或16进制转浮点数),程序运行后不退出,持续等待输入。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 双向浮点数与16进制内存转换工具 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
