博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串操作练习:星座、凯撒密码、99乘法表、词频统计预处理
阅读量:4569 次
发布时间:2019-06-08

本文共 2413 字,大约阅读时间需要 8 分钟。

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

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

 

 

恺撒密码的编码

sr1="abcdefghijklmnopqrstuvwxyz"sr2=sr1.upper()sr=sr1+sr1+sr2+sr2st=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)

 

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

name=input("please input:")print(name.center(4,' '))

 

 

中华人民共和国国内生产总值(GDP)

689,136.89亿元(2015年)

print("中华人民共和国国内生产总值(GDP){:,.2f}亿元(2015年)".format(689136.89))

 

 

实例:打出99乘法表

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

 

 

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

sr='''Just one last dance ,oh baby just one last dance!We meet in the night in the Spanish café,I look in your eyes just don't know what to say,It feels like I'm drowning in salty water,A few hours left 'til the sun's gonna rise,tomorrow will come an it's time to realize.our love has finished forever,how I wish to come with you!how I wish we make it through!Just one last dance!before we say goodbye,when we sway and turn round and round and round,it's like the first time,Just one more chance,hold me tight and keep me warm.cause the night is getting cold.and I don't know where I belong,Just one last dance! '''print("dance出现次数:",sr.count('dance'))for i in sr:    sr=sr.replace(',',' ')    sr=sr.replace('!',' ')    sr=sr.replace('?',' ')print(sr)for i in sr:    sr=sr.lower()print(sr)

 

 

sr='''Just one last dance ,oh baby just one last dance!We meet in the night in the Spanish café,I look in your eyes just don't know what to say,It feels like I'm drowning in salty water,A few hours left 'til the sun's gonna rise,tomorrow will come an it's time to realize.our love has finished forever,how I wish to come with you!how I wish we make it through!Just one last dance!before we say goodbye,when we sway and turn round and round and round,it's like the first time,Just one more chance,hold me tight and keep me warm.cause the night is getting cold.and I don't know where I belong,Just one last dance! '''print("dance出现次数:",sr.count('dance'))for i in sr:    sr=sr.replace(',',' ')    sr=sr.replace('!',' ')    sr=sr.replace('?',' ')print(sr)for i in sr:    sr=sr.lower()print(sr)

 

 

webbrowser打开校园新闻列表

import webbrowser as webi=input("please input number:")web.open_new_tab('http://news.gzcc.cn/html/xiaoyuanxinwen/'+str(i)+'.html')

 

转载于:https://www.cnblogs.com/amzinghui/p/7544600.html

你可能感兴趣的文章
深度(Depth)概念
查看>>
linux - camera capture
查看>>
架构设计之Spring-Session分布式集群会话管理【转】
查看>>
给HTML拍个照(如何将html元素转成图片)
查看>>
接口测试测什么?
查看>>
数据库构架设计中的Shared Everthting、Shared Nothing、和Shared Disk
查看>>
小程序调用支付报错:jsapi缺少参数: total_fee
查看>>
地址总线、数据总线、控制总线详解
查看>>
Android BroadcastReceiver(一)
查看>>
复制目录下所有文件(隐藏文件与非隐藏文件)
查看>>
散点图--python库--matpolitlib
查看>>
信数金服: 决策管理和进件管理-Part 2
查看>>
CodeVs[3145 汉诺塔游戏]
查看>>
【敏捷开发】结对编程
查看>>
[Linux] 进程
查看>>
Windows命令
查看>>
VBS常用
查看>>
---Ubuntu 下安装AS的问题汇总!
查看>>
images for flutter
查看>>
前端学习-jQuery
查看>>