书生大模型实战营第三期——入门岛——python基础知识

第二关:python基础知识

任务如下:

任务描述
闯关任务 Python实现wordcount
闯关任务 Vscode连接InternStudio debug笔记

1 Vscode连接InternStudio

见第一关教程中vscode远程连接部分。

书生大模型实战营第三期------入门岛------Linux基础知识-CSDN博客

2 Python实现wordcount

python 复制代码
def word_count(text):
    import re
    words = re.findall(r'\b\w+\b', text.lower())
    word_dict = {}
    for word in words:
        if word in word_dict:
            word_dict[word] += 1
        else:
            word_dict[word] = 1
    return word_dict

input_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."""

output = word_count(input_text)
print(output)

3 Vscode连接InternStudio debug笔记

相关推荐
I Promise347 分钟前
多传感器融合&模型后处理C++工程师面试参考回答
开发语言·c++·面试
hef28813 分钟前
SQL和Python怎么选?数据分析工具实战指南
python·sql·数据分析
徐安安ye14 分钟前
FlashAttention长程依赖建模:局部+全局的Hybrid Spiral结构设计
python·深度学习·机器学习
2501_9327502619 分钟前
Java反射机制基础入门
java·开发语言
IT策士35 分钟前
Django 从 0 到 1 打造完整电商平台:商品排序与浏览量统计
后端·python·django
霍霍的袁36 分钟前
【C++初阶】函数重载详细讲解
开发语言·c++·算法
threelab36 分钟前
Three.js 黑洞引力效果着色器 | 三维可视化 / AI 提示词
开发语言·javascript·着色器
godspeed_lucip37 分钟前
LLM和Agent——专题3: Agentic Workflow 入门(4)
人工智能·python
godspeed_lucip41 分钟前
LLM和Agent——专题3: Agentic Workflow 入门(2)
网络·人工智能·python
mingshili42 分钟前
[Python] Python中自带模块级的单例模式-不需要定义单例类
python·单例模式