zoukankan      html  css  js  c++  java
  • 字符串练习

    字符串练习:

    http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html
    

    取得校园新闻的编号

    str = 'http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html'
    print(str[-14:-5])
    https://docs.python.org/3/library/turtle.html
    

    产生python文档的网址

    addr1 = 'https://docs.python.org/3/library/'
    addr2 = ['turtle', 'index', 'sys']
    addr3 = '.html'
    for i in addr2:
        print(addr1 + i + addr3)
    

    产生校园新闻的一系列新闻页网址

    for i in range(2, 231):
        address = 'http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html'.format(i)
        print(address)
    

    用函数得到校园新闻编号

    addr = 'http://news.gzcc.cn/html/2018/xiaoyuanxinwen_0308/9005.html'
    print(addr.rstrip('.html')[-9:])
    

    用函数统计一歌词中单词出现的次数

    song = '''I never knew
    When the clock stopped and I'm looking at you
    
    I never thought I'll miss someone like you
    
    Someone I thought that I knew
    
    I never knew
    
    I should have known something wouldn't be true
    
    Baby you know that I'm so into you
    
    More than I know I should do
    
    So why why why
    
    Why should we waited
    
    And I I I
    
    I should be waiting
    
    Waiting for someone new
    
    Even though that it wasn't you
    
    But I know that it's
    
    Wonderful
    
    Incredible
    
    Baby irrational
    
    I never knew it was obsessional
    
    And I never knew it was with you oooh
    
    Baby if it's just
    
    Wonderful
    
    Incredible
    
    Baby irrational
    
    I never knew it was so sad
    
    Just so sad
    
    I'm so sorry
    
    Even now I just cannot feel you feel me
    
    Hmmm
    
    So why why why
    
    Why should we waited
    
    And I I I
    
    I should be waiting
    
    Waiting for someone new
    
    Even though that it wasn't you
    
    But I know that it's
    
    Wonderful
    
    Incredible
    
    Baby irrational
    
    I never knew it was obsessional
    
    And I never knew it was with you oooh
    
    Baby if it's just
    
    Wonderful
    
    Incredible
    
    Baby irrational
    
    I never knew it was so sad
    
    Just so sad
    
    I'm so sorry
    
    Even now I just cannot feel you fall
    
    I don't even know now
    
    I'm sure you'll wait for me
    
    Even now I just cannot deny
    
    I just hold on so tight
    
    Until you and I never could breathe
    
    Oh
    
    Wonderful
    
    Incredible
    
    Baby irrational
    
    I never knew it was obsessional
    
    And I never knew it was with you until you tell me to
    
    Baby if it's just
    
    Wonderful
    
    Incredible
    
    Baby irrational
    
    I never knew it was so sad
    
    Just so sad
    
    I'm so sorry
    
    Even now I just cannot feel you feel me
    
    '''
    print(song.count('Wonderful'))
    

     将字符串分解成一个个的单词。

    a = 'I love study Python!'
    print(a.split())
    

      

  • 相关阅读:
    C#与独孤九剑
    C#系列视频教程字符和字符串操作
    【设计模式】迪米特法则
    【设计模式】考题 模板方法模式
    C#字符和字符串
    【热门技术】解决Win7 下面很多软件安装不兼容的问题
    C#使电脑发出嗡鸣声
    C#视频教程下载(第一章)
    【设计模式】牛市股票还会亏钱 外观模式
    【设计模式】好菜每回味不同 建造者模式
  • 原文地址:https://www.cnblogs.com/FZW1874402927/p/8616706.html
Copyright © 2011-2022 走看看