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 ...
随机推荐
- 深度学习-RNN
目录 I.前言 介绍RNN的概念和应用 II. RNN基础 RNN的概念和结构 RNN的前向传播和反向传播算法 前向传播算法 反向传播 RNN的变种:LSTM和GRU LSTM GRU III. RN ...
- JZOJ 3213. 【SDOI2013】直径
题目 思路 树的直径很好求,两遍 \(dfs\),记下两个端点 然后很显然所有直径经过的边必然在我们求出的这条直线上 那么我们只要判断一下一条直径上的边是不是答案 假设当前边为 \(i\) 那么把 \ ...
- Win下依据端口排查步骤
Win下依据端口排查步骤 目录 Win下依据端口排查步骤 1 排查步骤 2 参考 今天突然发现自己电脑出现7680端口的内网连接,决定看看这个端口是做什么用的 1 排查步骤 确认7680端口连接情况与 ...
- SpringBoot2.6.x及以上版本整合swagger文档
SpringBoot的版本更新中引入了一些新的特性,并且Swagger的版本更新也同样引入了很多新的东西,这样就造成了许多配置无法实现一一对应的情况,因此高版本的SpringBoot集成Swagger ...
- 拥抱下一代前端工具链-Vue老项目迁移Vite探索
作者:京东物流 邓道远 背景描述 随着项目的不断维护,代码越来越多,项目越来越大.调试代码的过程就变得极其痛苦,等待项目启动的时间也越来越长,尤其是需要处理紧急问题的时候,切换项目启动,等待的时间就会 ...
- 如何调用别人的接口(包含get请求post请求)
对于如何调用第三方接口还是有些模糊,所以记录一下,上代码 package com.zhang.miaodou; import java.io.BufferedReader; import java.i ...
- kubebuilder简明教程
一.operator概述 Operator 是 Kubernetes 的扩展软件,它利用 定制资源 管理应用及其组件. Operator 遵循 Kubernetes 的理念,特别是在控制器 方面[1] ...
- 查询自增ID断点的地方
方法一 SELECT id+1 AS ID FROM table WHERE id+1 not in (SELECT id FROM table);
- sql两种表联查更新的方法
1.update ceshi c1,ceshi2 c2 set c1.num=c2.aa where c1.id=c2.cid; 2.update ceshi c1 INNER JOIN ceshi2 ...
- [PHP]流程控制的替代语法:endif/endwhile/endfor使用介绍
我们经常在wordpress一类博客程序的模板里面看到很多奇怪的PHP语法,比如: 代码如下: <?php if(empty($GET_['a'])): ?> <font color ...