字符串操作练习:星座、凯撒密码、99乘法表、词频统计预处理

for i in range(12):
    print(chr(9800+i),end="/")

sr1="abcdefghijklmnopqrstuvwxyz"
sr2=sr1.upper()
sr=sr1+sr1+sr2+sr2
st=input("please input:")
sR=""
for j in st:
    if j==" ":
        sR = sR +" "
        continue
    i=sr.find(j)
    if(i>-1):
        sR=sR+sr[i-3]
print(sR)

a=input("please input:")
print("{0: ^4}".format(a))

a=float(input("输入生产总值"))
b=input("输入年份")
print("{1}年的生产总值是:{0:,.2f}亿元".format(a,b))

for x in range(1,10):
    for y in range(1,x+1):
        print("{}*{}={}".format(x,y,x*y),end=" ")
    print("\n")

w='''I need you boo and I see you boo
And the heart's all over the world tonight
Said the heart's all over the world tonight
Hey, little mama, ooh you're a winner
Hey, little mama, yes you're a winner
I'm so glad to be yours
You're a class all your own and
Ooh, little cutie, when you talk to me
I swear the whole world stops
You're my sweetheart
I'm so glad that you're mine
You are one of a kind and
You mean to me
What I mean to you and
Together baby
There is nothing we won't do
'Cause if I got you
I don't need money
I don't need cars
Girl, you're my all
And oh, I'm into you
Girl, no one else would do
'Cause with every kiss and every hug
You make me fall in love
And now I know I can't be the only one
I bet there's hearts all over'''
print("need出现的次数",w.count('need'))
for i in w:
    w=w.replace(","," ")
    w=w.replace("?"," ")
    w=w.replace("!"," ")
    for i in w:
        w=w.lower()
print(w)

import webbrowser
a=input("输入想要打开的页数:")
webbrowser.open_new_tab('http://news.gzcc.cn/html/xiaoyuanxinwen/'+str(a)+'.html')

posted @ 2017-09-18 15:43  36-林秋雁  阅读(130)  评论(0编辑  收藏  举报