python

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]'

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值