python36
无限循环
如果条件判断语句永远为 true,循环将会无限的执行下去,如下实例:
实例
以上实例输出结果:
Enter a number :20
You entered: 20
Enter a number :29
You entered: 29
Enter a number :3
You entered: 3
Enter a number between :Traceback (most recent call last):
File "test.py", line 5, in <module>
num = raw_input("Enter a number :")
KeyboardInterrupt
注意:以上的无限循环你可以使用 CTRL+C 来中断循环。
循环使用 else 语句
在 python 中,while … else 在循环条件为 false 时执行 else 语句块:
实例
count = 0
while count < 5:
print count, " is less than 5"
count = count + 1
else:
print count, " is not less than 5"
以上实例输出结果为:
0 is less than 5
1 is less than 5
2 is less than 5
3 is less than 5
4 is less than 5
5 is not less than 5
简单语句组
类似 if 语句的语法,如果你的 while 循环体中只有一条语句,你可以将该语句与while写在同一行中, 如下所示:
实例
flag = 1
while (flag): print 'Given flag is really true!'
print "Good bye!"
python36的更多相关文章
- Python36 二进制文件读写问题
在Python36中写如下代码: __author__ = '-------'#-*- coding: utf-8 -*-import struct fo = open("myfile.tx ...
- centos 安装 python36
centos6 安装 python36 临时方法: https://www.softwarecollections.org/en/scls/rhscl/rh-python36/ 方法二: http:/ ...
- 【Selenium】【BugList4】执行pip报错:Fatal error in launcher: Unable to create process using '""D:\Program Files\Python36\python.exe"" "D:\Program Files\Python36\Scripts\pip.exe" '
环境信息: python版本:V3.6.4 安装路径:D:\Program Files\python36 环境变量PATH:D:\Program Files\Python36;D:\Program F ...
- python(1)在windows8.1下搭建python27和python36环境
去Python官网下载需要的Python版本 https://www.python.org/ 我下载的是下面这两个版本: Python 2.7.13 Python 3.6.1 安装Python27时, ...
- windows7+cuda8+cudnn6+python36+tensorflow_gpu1.4配置
下载文件 cuda8,自行网上下载online的安装包就好了 cudnn6 python36 tensorflow_gpu 下载地址:https://pan.baidu.com/s/1mjwOi5E ...
- Python36和Python27共存的方法
Python26和Python37环境的配置 设置环境变量 我的电脑右键属性-高级系统属性-环境变量 选择系统变量中的Path,双击打开 加入你的Python安装路径 C:\Python27;C:\P ...
- pip安装lxml报错 Fatal error in launcher: Unable to create process using '"c:\users\administrator\appdata\local\programs\python\python36\python.exe" "C:\Users\Administrator\AppData\L
pip install lxml 安装报错 E:\apollo\spider_code>Fatal error in launcher: Unable to create process usi ...
- RuntimeError: Failed to init API, possibly an invalid tessdata path: E:\python36\报错
OCR:光学识别符,tesserocr是python中一个OCR识别库,是对tesseract做的一个python的 API封装,所以它的核心是tesseract 在这里我安装的版本是:tessera ...
- 通过离线安装包解决了 from cryptography.hazmat.bindings._openssl import ffi, lib ImportError: /usr/local/python36/lib/python3.6/site-packages/cryptography-2.2.2-py3.6-linux-x86_64.egg/cryptography/hazmat/binding
场景:内网服务器不能上外网(代理也不通!), 之前安装了PYTHON的几个安装包,但不是知道为什么无法使用PARAMIKO这个模块 在导入 from cryptography.hazmat.bindi ...
- ()centos7 安装python36
centos7 默认安装 python2.7 1.先安装python36和对应pip yum install python-pip #安装python2的pip yum install python3 ...
随机推荐
- 【linux系统安装】Anolis OS-龙蜥操作系统实机安装流程整理
[安装准备] 1.准备一个U盘,可储存空间不低于20G,U盘内资料移出去,待会儿要格式化做U盘启动盘 2.windows操作系统上下载"Rufus",官网:http://rufus ...
- pat乙级 1019 数字黑洞
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> ...
- 【转】IDEA搭建SSM框架(spring+maven+mybatis+mysql+junit)
环境安装: apache-tomcat-9.0 https://tomcat.apache.org/download-90.cgi 配置:https://blog.csdn.net/qq_415706 ...
- Corundum:100G NIC学习(二)——仿真
前情提要:搭建corundum仿真环境(一)https://www.cnblogs.com/shroud404/articles/15364812.html 三.Running test 接上文,梳理 ...
- 自定义StringByteLength
using HKElectric.ESafety.Utilities; using System.ComponentModel.DataAnnotations; namespace HKElectri ...
- 如何删除Word文档中的空白页
需求 平常我们写 Office 文档的时候,经常会不小心多加几页空白,那么如何删除 word 文档中的空白页呢? 小编结合网友提供的办法和亲身测试的操作经验,给大家提供几个可行的方案. 原文:如何删除 ...
- leetcode刷题(二)
1.栈 逆波兰表达式求值 根据逆波兰表示法,求表达式的值. 有效的运算符包括 +, -, *, / .每个运算对象可以是整数,也可以是另一个逆波兰表达式. 说明: 整数除法只保留整数部分.给定逆波兰表 ...
- linux中磁盘如何由dos格式怎么变为gpt格式
一般情况下,我们进行磁盘分区管理使用gdisk命令比较方便快捷,但假如我们想要大于2T的磁盘使用fdisk命令已经无法使用,此刻我们该怎么办?这时我们可以使用parted命令来把磁盘转换为gpt格式, ...
- vscode开发vue3+ts环境搭建
一.开发环境准备 1.nvm 2.vscode 3.node 4.chome 5.git 6.npm install -g yarn tyarn 7.tyarn global add commitiz ...
- CentOS 镜像官网下载链接
CentOS 镜像官网下载链接: https://www.centos.org/download/mirrors/ http://mirrors.aliyun.com/centos/ https:// ...