当前位置: 首页> 房产> 市场 > 书生大模型实战营-入门关卡-Python 基础知识

书生大模型实战营-入门关卡-Python 基础知识

时间:2025/7/11 1:15:23来源:https://blog.csdn.net/lilai619/article/details/140998404 浏览次数:0次

任务: https://github.com/InternLM/Tutorial/blob/camp3/docs/L0/Python/task.md

完成:

任务1:Python实现wordcount

import re
from collections import defaultdictdef wordcount(text):# 转换为小写并使用正则表达式分割单词words = re.findall(r'\b\w+\b', text.lower())# 使用 defaultdict 来自动处理字典中不存在的键word_counts = defaultdict(int)# 统计每个单词出现的次数for word in words:word_counts[word] += 1return dict(word_counts)if __name__ == "__main__":# 示例text = "One, world! one dream."result = wordcount(text)print(result)

任务2:Vscode连接InternStudio debug笔记

 

关键字:书生大模型实战营-入门关卡-Python 基础知识

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: