书生训练L0-python关卡,完成wordcont函数统计单词出现的次数

一、任务目标:

输入字符串:

"""Hello world!  
This is an example.  
Word count is fun.  
Is it fun to count words?  
Yes, it is fun!"""

输出:

{'hello': 1, 'world': 1, 'this': 1, 'is': 4, 'an': 1, 'example': 1, 'word': 1, 'count': 2,
'fun': 3, 'it': 2, 'to': 1, 'words': 1, 'yes': 1}

1、安装conda

直接安装anaconda(在官网选择安装版本即可),anaconda的好处是包含大多数可以使用到的库,集成很多种代码开发的运行环境

2、创建一个新的python环境

打开anaconda命令窗口,输入

conda create -n python-tutorial(环境名) python=3.10(python版本)

(创建新环境的主要原因是避免所使用库之间的版本报错问题)

再运行环境

activate python-tutorial

使用 conda env list 已有查看环境使用 conda activate python-tutorial 更改运行环境,使用pip install 下载 numpy 和jupyter lab并运行 jupyter lab

3、解决问题

解决任务目标的代码如下:

二、在vscode上SSH连接开发机运行python debug

1、debug单个文件

将上面写的代码复制到开发机中新建的python_debug_test.py文件中,在左端点击红点设置中断点

2、在vscode中使用命令进行debug

点击VSCode侧边栏的“Run and Debug”(运行和调试),单击"create a lauch.json file"

将要运行的代码打好断点 然后在终端运行代码

python -m debugpy --listen 5678 --wait-for-client ./python_debug_test.py

最后点击绿色按钮 实现命令debug

注:可能需要使用pip 安装 debugpy module 安装代码为 pip install debugpy。

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值