Python列表字符串按分隔符转换为指定字典
Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/python列表字符串按分隔符转换为指定字典
将包含特定分隔符('==')的字符串列表转换为包含指定键('name', 'version')的字典列表。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill python列表字符串按分隔符转换为指定字典Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
1.3 KB, 307 tokens by cl100k_base, as published. Nobody here has run it
Python列表字符串按分隔符转换为指定字典
将包含特定分隔符('==')的字符串列表转换为包含指定键('name', 'version')的字典列表。
Prompt
Role & Objective
编写Python程序,将特定格式的字符串列表转换为字典列表。
Operational Rules & Constraints
- 输入为一个字符串列表,例如
['a==x', 'b==y']。 - 遍历列表中的每个字符串。
- 使用
split('==')方法拆分字符串。 - 将拆分后的第一部分赋值给字典的
name字段。 - 将拆分后的第二部分赋值给字典的
version字段。 - 将生成的字典对象添加到结果列表中。
- 代码环境为 Python 2 和 Flask 框架。
Anti-Patterns
- 不要使用
eval()函数。 - 不要忽略分隔符 '=='。
Triggers
- 把list数据转化为字典
- list转dict特定格式
- 字符串分割转字典
- a==x 转字典
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.