zoukankan      html  css  js  c++  java
  • 字符串操作练习:星座、凯撒密码、99乘法表、词频统计预处理

    1、实例:输出12个星座符号,以反斜线分隔。

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

    2、实例:恺撒密码的编码

    复制代码
    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= ' ')
    复制代码

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

    s = input('input your name:')
    s = str(s)
    print('{0: ^75}'.format(s))

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

    GDP = input('中华人民共和国国内生产总值(GDP):')
    GDP = str(GDP)
    Year  = input('输入年份:')
    Year = int(Year)
    print('{}  :  {}'.format(Year,GDP))

    5、实例:打出99乘法表

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

    结果:

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

    import webbrowser as web
    url='http://news.gzcc.cn/html/xiaoyuanxinwen/'
    web.open_new_tab(url)
    for i in range(2,5):
        web.open_new_tab('http://news.gzcc.cn/html/xiaoyuanxinwen/'+str(i)+'.html')
  • 相关阅读:
    尚未笔记知识点
    jsonp的原理及其使用
    django中将views.py中的python方法传递给html模板文件
    UVA
    UVA
    UVA
    UVA
    UVA
    UVA 1600 Patrol Robot
    UVA
  • 原文地址:https://www.cnblogs.com/huanglinxin/p/7546042.html
Copyright © 2011-2022 走看看