书生大模型实战营第三期——入门岛——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笔记

相关推荐
XBodhi.7 分钟前
Visual Studio C++ 语法错误: 缺少“;”(在“return”的前面)
开发语言·c++·visual studio
麻雀飞吧24 分钟前
期货多合约策略目标持仓怎么更新才不乱
python·区块链
Cthy_hy34 分钟前
拓扑排序超详解:原理 + Kahn 贪心算法
python·算法·贪心算法
LSssT.44 分钟前
【01】Python 机器学习
开发语言·python
为爱停留1 小时前
给智能体装上「刹车」:中断(Interrupts)与人工审批全解析
python
l1t1 小时前
DeepSeek总结的使用实体-组件-系统和基于存在性处理进行Python编程39-40
开发语言·python
曾阿伦2 小时前
Python 搭建简易HTTP服务
开发语言·python·http
YG亲测源码屋2 小时前
java配置环境变量、jdk环境变量配置、java环境变量设置方法
java·开发语言
MIUMIUKK2 小时前
从语法层面,看懂 Python 的特殊处
java·开发语言·python
FlyWIHTSKY2 小时前
TS、TSX、JS、JSX 文件扩展名详解
开发语言·javascript·ecmascript