第三次

#(1)遍历列表
print('列表的遍历:')
a=[1,2,3];
for i in a:
    print(i);
#(2)遍历元组
print('元组的遍历:')
a=(4,5,6);
for i in a:
   print(i);
#(3)遍历集合
print('集合的遍历:')
a={7,8,9}
for i in a:
    print(i);
#(4)遍历字典
print('字典的遍历:')
a={"姓名":"唐僧洗头爱飘柔","性别":"男","学号":123456789};
for key in a.keys():
    print(key,":",a.get(key));

 

str2='''Cry on my shoulder 

If the hero never comes to you 

If you need someone you re feeling blue 

If you re away from love and you re alone 

If you call your friends and nobody s home 

You can run away but you can t hide 

Through a storm and through a lonely night 

Then I show you there s a destiny 

The best things in life 

They re free 

But if you wanna cry 

Cry on my shoulder 

If you need someone who cares for you 

If you re feeling sad your heart gets colder 

Yes I show you what real love can do 

If your sky is grey oh let me know 

There s a place in heaven where we ll go 

If heaven is a million years away 

Oh just call me and I make your day 

When the nights are getting cold and blue 

When the days are getting hard for you 

I will always stay here by your side 

I promise you I ll never hide 

What real love can do 

What love can do 

What real love can do 
 '''.lower()
print(str2)
str2 = str2.replace('’',' ')
str2 = str2.replace(':',' ')
str2 = str2.replace(',',' ')
str2 = str2.replace('.',' ')
str2 = str2.replace('?',' ')
str2 = str2.replace('!',' ')
str2 = str2.replace('\n',' ')
print(str2)
str2 = str2.strip()
str2 = str2.split(' ')
print(str2.count("love"))
print(str2)

 

bl = 'https://edu.cnblogs.com/campus/gzcc/14NetworkEngineering/homework/870'
bl1 = bl.split('/')
classmates = ['Michael', 'Bob', 'Tracy', '李三', 'Tracy']

print(classmates[-1])
print(classmates[1:3])
print(len(classmates))
print(max(classmates))
print(min(classmates))
print(classmates.index('Tracy'))
print(classmates.count('Tracy'))
classmates[1] = 'Sarah'
print(classmates[1])
classmates.sort()  # 没有返回值,改变列表本身
print(classmates)

classmates.insert(1, 'Jack')
print(classmates)

classmates.append('Adam')
print(classmates)
classmates.extend(bl1)
print(classmates)

print(classmates.pop())
print(classmates.pop(1))

 

 

转载于:https://www.cnblogs.com/liuyonghe/p/9753250.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值