欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 明星 > 大模型笔记-书生训练营第三期闯关指南 1.3 python

大模型笔记-书生训练营第三期闯关指南 1.3 python

2025/5/6 14:18:24 来源:https://blog.csdn.net/qqzhuimengren/article/details/140556232  浏览:    关键词:大模型笔记-书生训练营第三期闯关指南 1.3 python

大模型笔记-书生训练营第三期闯关指南 1.3 python

    • 1 闯关任务
    • 2 闯关任务

1 闯关任务

Python实现wordcount

import redef wordcount(text):# 使用正则表达式替换标点符号为空格text = re.sub(r'[.,;!?]', ' ', text)# 将文本分割成单词列表并转换为小写words = text.lower().split()# 创建一个字典来存储单词计数word_counts = {}# 遍历单词列表,更新字典中的计数for word in words:if word in word_counts:word_counts[word] += 1else:word_counts[word] = 1return word_counts# 示例用法
text = """
Got this panda plush toy for my daughter's birthday,
who loves it and takes it everywhere. It's soft and
super cute, and its face has a friendly look. It's
a bit small for what I paid though. I think there
might be other options that are bigger for the
same price. It arrived a day earlier than expected,
so I got to play with it myself before I gave it
to her.
"""
print(wordcount(text))

在这里插入图片描述

2 闯关任务

Vscode连接InternStudio debug笔记

注意:vscode安装了python插件,如果没有生效,重启vscode

g笔记

注意:vscode安装了python插件,如果没有生效,重启vscode

在这里插入图片描述

版权声明:

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

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

热搜词