python
2015-12-28 18:17
369 查看
and运算符就是所谓的布尔运算符,连接两个布尔值,并且在两者都为真时返回真,否则 返回假,or not 可以随意结合真值
短路逻辑 short-circuit logic 惰性求值 lazy evaluation
raw_input 返回值为真
断言,条件后可以添加字符串,用来解释断言
x = 1
Yes = input('Are you readly?')
if Yes.lower() == 'yes':
while x <= 'yes':
print(x)
x += 1
缩进对Python 太重要了!
name = ''
while not name:
name = input('Please enter your name: ')
print('Hello,%s!' % name)
Name = input('Please input you name: ')
name = Name
while not name or name.isspace():
#while not name.strip() or while not name or name.isspace()
#
name = input('Please enter your name: ')
print('Hello,%s!'% name)
# sequence list words = ['this','is','an','ex','parrot']
#for word in words:
# print(word)
"""
numbers = [0,1,2,3,4,5,6,7,8,9]
for number in numbers:
print(number)
"""
'''
d = {'x':1,'y':2,'z':3}
for key in d:
print(key,'corresponds to',d[key])
#multiline commit for python
#one line commeit for Python
'''
'''
d = {'x':1,'y':2,'z':3}
print(d[key])
#for key in d:
# print(d[value])
'''
'''
d = {'x':1,'y':2,'z':3}
for key,value in d.items():
print(key,'correspond to',value)
'''
"""
names = ['anne','beth','george','damon']
ages = [12,45,32,102]
for i in range(len(names)):
print(names[i],'is',ages[i],'years old')
for string in strings:
if 'xxx' in string:
index = strings.index(string) # Search for the string in the list of strings
strings[index] = '[censored]'
"""
for string in srings:
if 'xxx' in string:
index = strings.index(string)
strings[index] = '[censored]'
短路逻辑 short-circuit logic 惰性求值 lazy evaluation
raw_input 返回值为真
断言,条件后可以添加字符串,用来解释断言
x = 1
Yes = input('Are you readly?')
if Yes.lower() == 'yes':
while x <= 'yes':
print(x)
x += 1
缩进对Python 太重要了!
name = ''
while not name:
name = input('Please enter your name: ')
print('Hello,%s!' % name)
Name = input('Please input you name: ')
name = Name
while not name or name.isspace():
#while not name.strip() or while not name or name.isspace()
#
name = input('Please enter your name: ')
print('Hello,%s!'% name)
# sequence list words = ['this','is','an','ex','parrot']
#for word in words:
# print(word)
"""
numbers = [0,1,2,3,4,5,6,7,8,9]
for number in numbers:
print(number)
"""
'''
d = {'x':1,'y':2,'z':3}
for key in d:
print(key,'corresponds to',d[key])
#multiline commit for python
#one line commeit for Python
'''
'''
d = {'x':1,'y':2,'z':3}
print(d[key])
#for key in d:
# print(d[value])
'''
'''
d = {'x':1,'y':2,'z':3}
for key,value in d.items():
print(key,'correspond to',value)
'''
"""
names = ['anne','beth','george','damon']
ages = [12,45,32,102]
for i in range(len(names)):
print(names[i],'is',ages[i],'years old')
for string in strings:
if 'xxx' in string:
index = strings.index(string) # Search for the string in the list of strings
strings[index] = '[censored]'
"""
for string in srings:
if 'xxx' in string:
index = strings.index(string)
strings[index] = '[censored]'
相关文章推荐
- 使用python2时会遇到一系列显示中文字符的问题
- Python 中嵌入MFC的DLL实例
- python Slope one
- Python整数的缓存
- python知识-类的继承
- Python之斐波拉数列
- day10 python学习随笔
- 第一章:Python基础知识
- 使用python爬虫抓站的一些技巧总结:进阶篇
- Python进阶之路---1.2python版本差异
- Python编辑器安装
- Python安装setuptools的脚本
- Python 安装matplotlib,six,dateutil,pyparsing 完整过程
- Python文件写到本地
- MFC 使用Python脚本语言
- 【python】配置文件
- python入门到精通[一]:搭建开发环境
- Python 3.0中ACCESS学习(三) 打开记录集并输出数据
- python读取表格csv的方法
- python连接数据库出报表