python中while循环语句用法简单实例

yipeiwu_com6年前Python基础

本文实例讲述了python中while循环语句用法。分享给大家供大家参考。具体如下:

number = 1
while number < 20:
  print(number)
  number += 1

运行结果如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

希望本文所述对大家的Python程序设计有所帮助。

相关文章

Python 词典(Dict) 加载与保存示例

Dict的加载: import json def load_dict(filename): '''load dict from json file''' with open(f...

python使用xlrd与xlwt对excel的读写和格式设定

前言 python操作excel主要用到xlrd和xlwt这两个库,即xlrd是读excel,xlwt是写excel的库。本文主要介绍了python使用xlrd与xlwt对excel的读...

Python实现简单字典树的方法

本文实例讲述了Python实现简单字典树的方法。分享给大家供大家参考,具体如下: #coding=utf8 """代码实现了最简单的字典树,只支持由小写字母组成的字符串。 在此代码基...

python中的迭代和可迭代对象代码示例

什么是迭代(iteration)呢? 给定一个list或者tuple,通过for循环来遍历这个list或者tuple、这种遍历就是迭代(iteration)。只要是可迭代的对象都可以进行...

python加载自定义词典实例

如下所示: #加载词典 def load_dict_from_file(filepath): _dict = {} try: with io.open(filepat...