Python for循环的12种巧妙运用

Python for循环简介与使用方法 本文详细介绍了Python for循环的基本概念和使用方法。for循环是Python中的一种常见控制结构,用于遍历序列中的元素并执行特定操作。文章从基本语法入手,讲解了如何使用for循环遍历序列,同时介绍了range()函数的用法,以便更方便地创建循环。我们还讨论了嵌套for循环的应用,以及如何遍历字典中的键、值和键值对。 此外,文章还介绍了列表推导式的概念,以简洁的方式创建新列表。同时,我们还讨论了使用enumerate()函数在for循环中同时访问序列中的元素及其索引的方法。 阅读详情

在这里插入图片描述


1.基础篇:Hello, For Loop!
  • 想象一下,你想给班上的每位同学发送“Hello!”,怎么办?看Python如何一招搞定:
names = ["Alice", "Bob", "Charlie"]  
for name in names:  
    print(f"Hello, {name}!")  

  • 这段代码就像一个邮递员,挨家挨户(遍历列表中的每个名字)送信(打印问候语)。

2.计数助手:enumerate来帮忙
  • 给每个同学编号,是不是更正式点?enumerate函数能助你一臂之力:
for i, name in enumerate(names):  
print(f"{i+1}. Hello, {name}!")  

  • enumerate就像给你的名单加了页码,i是页码,name是名字。

3.列表生成式:简洁之美
  • 想要快速创建一个新列表,比如每个名字后面加个"!"?
excited_names = [f"{name}!" for name in names]  
print(excited_names)  

  • 这叫列表生成式,一行代码胜千言,效率与优雅并存!

4.范围函数range的魔法
  • 想数数?range函数是你的数字精灵:
for i in range(5):  # 从0到4  
print(i)  

  • 别小看它,循环次数控制全靠它!

5.嵌套循环:编织复杂图案
  • 记得小时候的九九乘法表吗?Python帮你轻松绘制:
for i in range(1, 10):  
    for j in range(1, i+1):  
        print(f"{j}x{i}={i*j}", end="\t")  
    print()  # 换行  

  • 两个循环相互嵌套,就像俄罗斯套娃一样,一层又一层。

6.break和continue:控制流的指挥棒
  • 遇到不喜欢的同学,直接跳过?continue出场:
for name in names:  
    if name == "Bob":  
        continue  
    print(f"Hello, {name}!")  

  • continue说:“Bob,你先休息一下,我去找下一个。”

7.else子句:循环的附加惊喜
  • 你知道吗?for循环后还能跟个else?
for i in range(5):  
    if i == 3:  
        break  
else:  
    print("循环顺利完成,没被break掉!")  

  • 如果循环正常结束,没有遇到break,else里的代码就执行。

8.使用zip:并行处理
  • 有两组数据要一起处理?zip函数让你左右开弓:
names = ["Alice", "Bob", "Charlie"]  
ages = [25, 30, 35]  
for name, age in zip(names, ages):  
    print(f"{name} is {age} years old.")  

  • zip就像一条神奇的纽带,把列表绑在一起。

9.遍历字典:键值对的舞蹈
  • 字典里的秘密,for也能探查:
my_dict = {"apple": 3, "banana": 5, "cherry": 7}  
for key, value in my_dict.items():  
    print(f"I have {value} {key}(s).")  

  • 通过.items(),每个键值对都跳起了双人舞。

10.逆序循环:时光倒流
  • 想反着数数,或者倒着念名字?用reversed函数:
for name in reversed(names):  
    print(f"Goodbye, {name}!")  

  • 时光倒流,从最后一个名字开始告别。

11迭代器与next函数:深海探险
  • 所有可迭代对象都可以用迭代器来玩:
it = iter(names)  
print(next(it))  # Alice  
print(next(it))  # Bob  

  • iter()制造潜水艇,next()带你潜入下一个宝藏。

12.高级技巧:列表推导结合条件判断
  • 结合条件,快速筛选出喜欢的名字:
vowel_start_names = [name for name in names if name[0].lower() in 'aeiou']  
print(vowel_start_names)  


高级技巧及应用

1.生成器表达式:轻量级迭代神器
  • 生成器是Python的一大特色,非常适合处理大数据流。看这个例子:
# 生成所有小于10的平方数,但不一次性加载到内存中  
squares = (i**2 for i in range(10))  
for square in squares:  
    print(square)  

  • 生成器表达式像是一张按需提供食物的菜单,而不是一次性端上所有菜肴。

2.列表推导与循环嵌套的高级应用
  • 当你需要处理多维数据时,嵌套的列表推导可以非常直观:
matrix = [  
    [1, 2, 3],  
    [4, 5, 6],  
    [7, 8, 9]  
]  
  
# 转置矩阵  
transposed = [[row[i] for row in matrix] for i in range(3)]  
for row in transposed:  
    print(row)  

  • 这段代码仿佛是在进行空间变换,将矩阵沿主对角线翻转。

3.利用itertools:循环的高级工具箱
  • Python的itertools模块提供了强大的迭代工具。比如,你想交替合并两个列表:
from itertools import chain  
  
list1 = [1, 2, 3]  
list2 = ['a', 'b', 'c']  
  
# 使用chain交替合并  
merged = list(chain.from_iterable(zip(list1, list2)))  
print(merged)  # 结果: [1, 'a', 2, 'b', 3, 'c']  

  • itertools就像一个瑞士军刀,里面藏着各种循环处理的利器。

4.循环效率优化:理解迭代原理
  • 了解Python的迭代机制能帮助你写出更高效的代码。例如,避免在循环内部进行列表的append操作,特别是在循环体很大时,可以考虑预分配列表大小或使用列表生成式。

5.循环与异常处理:稳健的循环
  • 在处理可能抛出异常的循环时,使用try-except可以增加代码的健壮性:
numbers = [1, 0, 3, 4]  
for num in numbers:  
    try:  
        print(1 / num)  
    except ZeroDivisionError:  
        print("Oops! Can't divide by zero.")  

  • 这样,即使遇到除以零的错误,循环也不会终止,而是优雅地处理异常。

最后

如果你觉得文章还不错,请大家 点赞、分享、留言 下,因为这将是我持续输出更多优质文章的最强动力!
最后这里免费分享给大家一份Python全台学习资料,包含视频、源码。课件,希望能帮到那些不满现状,想提升自己却又没有方向的朋友,也可以和我一起来学习交流呀。
编程资料、学习路线图、源代码、软件安装包等!【点击这里】领取!

① Python所有方向的学习路线图,清楚各个方向要学什么东西
② 100多节Python课程视频,涵盖必备基础、爬虫和数据分析
③ 100多个Python实战案例,学习不再是只会理论
④ 华为出品独家Python漫画教程,手机也能学习
⑤ 历年互联网企业Python面试真题,复习时非常方便****

在这里插入图片描述

在这里插入图片描述

python for循环巧妙运用(迭代、列表生成式) 介绍 我们可以通过for循环来迭代list、tuple、dict、set、字符串,dict比较特殊dict的存储不是连续的,所以迭代(遍历)出来的值的顺序也会发生变化。 最近开始整理python的资料,博主建立了一个qq群,希望给大家提供一个交流的平台 78486745 。 迭代(遍历) #!/usr/bin/env python3 #-*- coding:utf-8 -*- vlist=[... 阅读详情

相关推荐

Python中的for循环用法详解,一文搞定它

在Python中,for循环是一种迭代结构,用于遍历可迭代对象(如列表、元组、字符串、字典、集合等)中的元素。for循环可以解决while循环的局限性

景天科技苑 7430

Python for循环

Python for循环

Java癫疯的博客 9万+

Python中for循环的用法

本文介绍了Python中for循环的用法。无论是遍历列表、字符串、元组还是字典,我们都可以使用for循环来逐个访问其中的元素。此外,我们还学习了如何使用range()函数进行循环计数,以及如何使用循环控制语句来控制循环的执行流程。希望通过本文的介绍,你对Python中for循环有了更深入的理解。

HackNebulaZ的博客 275

python基础篇-for循环

for循环

清微的博客 4万+

退火朗之万动力学采样

退火朗之万动力学采样(Simulated Annealing Langevin Dynamics Sampling)结合了退火技术和朗之万动力学,是一种用于分子模拟和统计物理中的计算方法。这种方法可以帮助系统从局部最小值中逃逸,以找到全局最小值或进行有效的配置空间探索。

weixin_39699362的博客 1951

傻白入门芯片设计,SystemVerilog Assertion(SVA)学习(二十一)

对SVA(SystemVerilogt Assertion)有了更深刻的认识,对经典的AveMC形式验证工具进行了介绍

qq_46675545的博客 8474

【Python编程基础】12种for循环的巧妙运用,如果你正在学习Python,那一定要趁早收藏!

软件安装包、学习资料均已打包,需要的小伙伴可以戳这里。

m0_75067840的博客 4278

Debian 12 安装nodejs(包括node、npm、npx、yarn、pnpm、cnpm、bun)

【代码】Debian 12 安装nodejs。

mirana的专栏 8032

Python for循环的12种巧妙运用,如果你正在学习Python,那一定要趁早收藏!

书籍的好处就在于权威和体系健全,刚开始学习的时候你可以只看视频或者听某个人讲课,但等你学完之后,你觉得你掌握了,这时候建议还是得去看一下书籍,看权威技术书籍也是每个程序员必经之路。Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。最后,这里免费分享给大家一套免费的学习资料,包含视频、源码/电子书,希望能帮到那些不满现状,想提升自己却又没有方向的朋友,也可以加我微信一起来学习交流。

Python_HUHU的博客 2262

生成模型实战 | ProGAN详解与实现

Progressive GAN (ProGAN) 是一种通过渐进式增长网络结构来生成高分辨率、高保真图像的技术。传统 GAN 难以直接生成超过 256x256 分辨率的图像,而 ProGAN 创新性地从低分辨率开始训练生成器和判别器,逐步添加网络层以提高分辨率,直至达到1024x1024。该方法结合了像素归一化、小批次统计信息和均衡化学习率等关键技术,并使用 WGAN-GP 损失函数确保训练稳定性。ProGAN 是首个能生成1024x1024高保真人脸图像的模型,但其训练耗时较长,且对计算资源要求较高。

盼小辉丶的博客 1435

【华为OD技术面试手撕真题】1、长度最小的子数组 | 手撕真题+思路参考+代码解析(C & C++ & Java & Python & JS)(三种解法)

【华为OD面试手撕真题】长度最小的子数组,本专栏更新每年华为OD机试的高频手撕代码题,每个题目都会使用五种语言进行解答(C & C++& Java & Python & JS),思路分析都非常详细, 实现最低的时间复杂度和高通过率,每个解题思路超过百字,内含各个编程语言的八股文面试题,欢迎大家订阅学习, 代码可以直接运行使用,全网限时最低价,持续更新

KJ.JK 1万+

python for循环的用法_浅谈python for循环的巧妙运用(迭代、列表生成式)

介绍我们可以通过for循环来迭代list、tuple、dict、set、字符串,dict比较特殊dict的存储不是连续的,所以迭代(遍历)出来的值的顺序也会发生变化。迭代(遍历)#!/usr/bin/env python3#-*- coding:utf-8 -*-vlist=['a','b','c']vtuple=('a','b','c')vdict={'a': 1, 'b': 2, 'c': 3...

weixin_39527879的博客 894

Android 13.0 Launcher3中去掉Hotseat功能实现

在13.0系统产品定制化开发中,在Launcher3的定制化需求也是特别多的,由产品是小屏幕的产品,所以产品需求Launcher3 页面布局的原因,要求Launcher3 需要去掉Hotseat 不显示Hotseat下面几个图标,而做满屏app的显示,从而达到美观的效果,下面就来分析去掉Hotseat从而实现这个功能

安卓兼职framework和app工程师的博客 1330

2.12 Python for 循环

1. for 循环语句 2. for 遍历 2.1 遍历字符串 2.2 遍历列表 2.3 遍历元组 2.4 遍历字典 2.5 遍历集合 3. 多个迭代变量 4. range 序列类型 4.1 序列类型 4.2 终止位参数 4.3 起始位参数 4.4 间隔参数 4.5 遍历整数序列 4.6 range 版本区别 5. for + break 6. for + continue 7. for + else 8. for 嵌套 9. 练习

清风 1844

(9-2)离线强化学习:离线强化学习的主流方法

本文介绍了三种离线强化学习的主流约束策略优化方法:BCQ、CQL和Fisher-BRC,并通过CartPole环境进行性能比较。BCQ利用生成模型约束动作选择并引入扰动网络;CQL通过正则化Q值抑制对未见状态-动作对的高估;Fisher-BRC使用Fisher散度正则化策略分布。实验结果表明,三种方法各有优势,其中CQL表现最为稳定。文章还指出,为获得更好的性能,需要更大的数据集和更长的训练轮次。这些方法通过限制策略优化范围,有效提高了离线强化学习的稳定性和泛化能力。

码农三叔 1545

Android HAL 架构详解,底层开发不再难

HAL Binder 这套机制牛在哪?性能:一次拷贝,快如闪电。规范:HIDL 让接口定义整齐划一,维护省心。兼容:版本管理做得好,新老设备都能跑。有了这套通信体系,HAL 就像打了通脉,上下贯通,硬件操作变得丝滑无比。通信机制搭好了桥,接下来 HAL 得真正把手伸到硬件上。这部分是 HAL 的 “最后一公里”,直接决定硬件能不能被用起来。HAL 的接口定义是整个体系的灵魂,它决定了上层和底层怎么 “说话”。

大模型大数据攻城狮的专栏 1674

python基础教程:浅谈python for循环的巧妙运用(迭代、列表生成式)

@本文来源于公众号:csdn2299,喜欢可以关注公众号 程序员学府 下面小编就为大家带来一篇浅谈python for循环的巧妙运用(迭代、列表生成式)。 介绍 我们可以通过for循环来迭代list、tuple、dict、set、字符串,dict比较特殊dict的存储不是连续的,所以迭代(遍历)出来的值的顺序也会发生变化。 迭代(遍历) #!/usr/bin/env python3 #-*- co...

python函数基础教程 1378

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

python for循环 return_巧妙处理 return 遇上 for 循环

python 小知识点:函数中怎么在 for 循环后 返回列表的全部元素?什么?有点晕,那就举例看看我们先看一个简单的 for 循环的栗子:我们的需求是:返回 i 的全部元素我们现在把这个循环放在函数中,我们直接调用函数看看。结果等于 1 ,为啥?因为 for 循环一旦遇到 return 就会马上终止循环,当 i 第一次循环到 1 时遇到了 return 就马上停止并返回了,所以调用时函数返回的 ...

weixin_39684495的博客 3884

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

巧妙处理 return 遇上 for 循环

“ 阅读文本大概需要 3 分钟前言大家好,这里是「brucepk」零基础学习 Python 系列教程。此文首发于「brucepk」公众号,欢迎大家关注。今天给大家带来的是 pytho...

Python知识圈 9482

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

python的for循环

上节中,我们理解了什么是,学会用循环让计算机处理一系列重复的任务,并且走入海绵宝宝的世界,运用掌握的第一种循环结构——while循环,帮他从繁琐的工作中解放出来。你还记得while循环的结构吗?“魔法”家族的另一个重要成员——for循环。

qq_31667253的博客 932
上一篇: Python程序员必备工具之Conda安装及环境搭建设置_python conda如何安装
下一篇: 【Python背记手册】强烈建议!所有Python基础差的同学,死磕这本64页的背记手册!!
HUHU爱学习
博客等级 码龄4年 1221粉丝 75原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值