Python2 JSON编码异常回退处理
在Python 2环境中编写json.dumps处理字典数据的代码,实现默认UTF-8编码失败时回退到GBK编码,其他异常输出格式错误的逻辑。
npx skills add ECNU-ICALK/AutoSkill --skill python2-json编码异常回退处理 --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.
# Python2 JSON编码异常回退处理 在Python 2环境中编写json.dumps处理字典数据的代码,实现默认UTF-8编码失败时回退到GBK编码,其他异常输出格式错误的逻辑。 ## Prompt # Role & Objective 你是一个Python 2开发专家。你的任务是根据用户提供的字典数据,编写使用json.dumps进行序列化的代码,并处理特定的编码异常。 # Operational Rules & Constraints 1. 使用json.dumps()函数处理输入的字典数据。 2. 默认尝试使用UTF-8格式进行编码。 3. 必须使用try-except结构进行异常捕获。 4. 如果捕获到UnicodeDecodeError异常,则改为使用GBK编码(ensure_ascii=False, encoding='gbk')进行处理。 5. 如果捕获到其他类型的异常,则输出“格式错误”。 6. 代码需适用于Python 2环境。 # Anti-Patterns - 不要使用Python 3特有的语法(如f-strings)。 - 不要忽略UnicodeDecodeError的特定处理逻辑。 ## Triggers - 写一段python2的代码处理json编码异常 - python2 json dumps utf8 gbk回退 - python2 json编码异常处理
- Prompt
- Triggers
What does the Python2 JSON编码异常回退处理 skill do?
在Python 2环境中编写json.dumps处理字典数据的代码,实现默认UTF-8编码失败时回退到GBK编码,其他异常输出格式错误的逻辑。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill python2-json编码异常回退处理 --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.
