输出12个星座符号,以反斜线分隔。

for i in range(12):
    print(chr(9800+i),end='\\')

恺撒密码的编码

m = input("请输入加密字符:")
q=ord('a')
p=ord('z')
print("加密结果为")
for i in m:
    if q<=ord(i)<=p:
        print(chr(q+(ord(i)-p+3)%26),end='')
    else:
        print(i,end='')

输入姓名,格式输出:占4位、居中、不足4字的以空格填充。

name=input('输入姓名:')
print('名字是:{:^4}'.format(name))

格式化输出:中华人民共和国国内生产总值(GDP)689,136.89亿元(2015年)(千分位、2位小数,浮点数)

print("中华人民共和国国内生产总值(GDP):{0:^-10,.3f}亿元".format(689,136.89))

实例:打出99乘法表

for i in range(1,10):
    for j in range(1, i+1):
            print('{}x{}={}\t'.format(j, i, i*j), end='')
    print()

实例: 下载一首英文的歌词或文章,统计单词出现的次数,将所有,.?!替换为空格,将所有大写转换为小写。

song='''"every night in my dreams 
i see you, i feel you,
that is how i know you go on 
far across the distance 
and spaces between us 
you have come to show you go on 
near, far, wherever you are 
i believe that the heart does go on 
once more you open the door 
and you're here in my heart 
and my heart will go on and on 
love can touch us one time 
and last for a lifetime 
and never let go till we're one 
love was when i loved you 
one true time i hold to 
in my life we'll always go on 
near, far, wherever you are 
i believe that the heart does go on 
once more you open the door 
and you're here in my heart 
and my heart will go on and on 
there is some love that will not go away 
you're here, there's nothing i fear,
and i know that my heart will go on 
we'll stay forever this way 
you are safe in my heart 
and my heart will go on and on"'''
song=song.replace(',',' ')
song=song.lower()
print('my计数为:',song.count('my'))
print('heart计数为:',song.count('heart'))
print('歌词为:',song)

 

用webbrowser,uweb.open_new_tab('url')打开校园新闻列表

import webbrowser as web
for i in range(2,6):
    web.open_new_tab('http://news.gzcc.cn/html/xiaoyuanxinwen/'+str(i)+'.html')

 

posted on 2017-09-18 18:47  18-刘卓辉  阅读(210)  评论(0编辑  收藏  举报