zoukankan      html  css  js  c++  java
  • 第一章:变量和简单的数据类型

    字符串:

    使用方法修改字符串的大小写

    使用方法.title()改修字符串中每个单词首字母为大写

    a= "asd dfsdf"
    print(a.title())
    执行结果:
    Asd Dfsdf

    使用+拼接字符串

    a = "shen"
    b = "yile"
    c = a + " " + b
    print(c.title())
    执行结果:
    Shen Yile

    使用制表符 和换行符 添加空格

    a = "shen"
    b = "yi	le"
    c = a + "
    " + b
    print(c.title())
    执行结果:
    Shen
    Yi    Le

    使用方法rstrip、lstrip、strip删除末尾、开头、和开头结尾空格

    疑问:字符串中间的空格怎么去除?

    使用str()函数避免类型错误

    age = 23
    message = "Happy " + str(age) + "rd Birthday!"
    print(message)
    执行结果:
    Happy 23rd Birthday!
  • 相关阅读:
    Gym
    HDU
    HDU
    POJ
    洛谷P3690 Link Cut Tree (动态树)
    Gym
    P4294 [WC2008]游览计划 (斯坦纳树)
    洛谷P3264 [JLOI2015]管道连接 (斯坦纳树)
    HDU
    Controller调试接口
  • 原文地址:https://www.cnblogs.com/sxdpython/p/12591691.html
Copyright © 2011-2022 走看看