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 ...
随机推荐
- 数位 dp,但是做题笔记
这玩意儿还要学自己推不出来的 SX 是屑. 数位 dp,顾名思义,是根据数位做 dp,每个数位每个数位转移,炒个例子 windy 数. 求 \([l, r]\),我们改成求 \(1\sim r\) 与 ...
- 三天吃透MySQL八股文(2023最新整理)
本文已经收录到Github仓库,该仓库包含计算机基础.Java基础.多线程.JVM.数据库.Redis.Spring.Mybatis.SpringMVC.SpringBoot.分布式.微服务.设计模式 ...
- 代码随想录算法训练营day17 | leetcode ● 110.平衡二叉树 ● 257. 二叉树的所有路径 ● 404.左叶子之和
LeetCode 110.平衡二叉树 分析1.0 求左子树高度和右子树高度,若高度差>1,则返回false,所以我递归了两遍 class Solution { public boolean is ...
- 未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序。(C# EXCEL导入demo)
1. 安装office包 https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=13255 2.需要在相应的IIS应用程序池启用 ...
- CF873F - Forbidden Indices
题意:对于一个字符串 \(S\),有一些位置是被 \(\text{Ban}\) 掉的. 对于这个字符串的所有子串,它的分数是(长度 \(\times\) 在没有被 \(\text{Ban}\) 掉的位 ...
- vue学习 第二天 CSS基础
CSS: 层叠样式表 ( Cascading Style Sheets ) 的简称 1.css简介 1)也是一种标记语言 2)主要用来设置html页面中,标签的样式. 3)css美化了html页面, ...
- centos8下安装gcc11
最近的云服务器使用的centos8,c以前编译器对c++20的新特性支持的较少,当前最新版的gcc对c++20的支持还是可以的,于是准备体验一下,首要就是升级gcc gcc官网:https://gcc ...
- Software_programming_automation_selenium
10:52:37 Table 获取 tr list 注意会无法正常遍历获取. 修正后正常 1 public SelectionCriteriaPage checkSpecifyTag(int coun ...
- 卸载K8s集群及k8s命令自动补全
一.配置命令自动补全 yum install -y bash-completion source /usr/share/bash-completion/bash_completion source & ...
- 【Go】时间
mysql中的datetime转时间戳 // 获取mysql中的datetime类型转时间戳 t := "2023-02-21T14:51:00+08:00" ts, _ := t ...