字符串操作等

中文变编码:

s='我是中国人,广州商学院'
for i in s:
     print(ord(i))

显示12星座:

print('12星座编码输出符号:')
for i in range(12):
    print(chr(9800+i),end='\t')

九九乘法表:

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

字符串对齐:

s1=input('输入姓名1:')
s2=input('输入姓名2:')
s3=input('输入姓名3:')
print('字符串是:{0:*>8}{1:*>8}{2:*>8}'.format(s1,s2,s3))

凯撒密码:

s=input('输入一个明文字符串:')
print('输出明文:',end=' ')
for i in s:
    if ord('a')<=ord(i)<=ord('z'):
        print(chr(ord('a')+(ord(i)-ord('a')+3)%26),end=' ')
    else:
        print(i,end= ' ')

歌词替换标点符号:

ge='''You're insecure
Don't know what for
you're turning heads When you walk through the door
You don't know Oh oh!
You don't know you're beautiful Oh oh?
That's what makes you beautiful.

'''
print(ge.count('you'))
for i in ge:
    ge1=ge.replace('!','/')
    ge2=ge1.replace('?','/')
    ge3=ge2.replace('.','/')
print(ge3.lower())

 

打开网页。

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

posted @ 2017-09-18 11:40  03郭丽红  阅读(206)  评论(0编辑  收藏  举报