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

相关推荐
2301_816651227 分钟前
C++中的享元模式变体
开发语言·c++·算法
1941s10 分钟前
Google Agent Development Kit (ADK) 指南 第四章:Agent 开发与编排
人工智能·python·langchain·agent·adk
m0_5832031310 分钟前
C++中的访问者模式变体
开发语言·c++·算法
浅念-17 分钟前
C ++ 智能指针
c语言·开发语言·数据结构·c++·经验分享·笔记·算法
布谷歌17 分钟前
Fastjson枚举反序列化:当字符串不是枚举常量名时,会发生什么?
开发语言·python
虚幻如影18 分钟前
python识别验证码
开发语言·python
今儿敲了吗18 分钟前
python基础学习笔记第七章——文件操作
笔记·python·学习
不染尘.18 分钟前
最小生成树算法
开发语言·数据结构·c++·算法·图论
Austin_YB19 分钟前
VScode中配置Python环境
ide·vscode·python
qq_4523962320 分钟前
【Python × AI】LangChain 深度剖析:从组件解耦到 LCEL 的逻辑美学
人工智能·python·ai·langchain