美文网首页
2018-07-23 Chapter 2.1 Ablout St

2018-07-23 Chapter 2.1 Ablout St

作者: 纤离 | 来源:发表于2018-07-23 10:27 被阅读0次

    《Python编程从入门到实践》
    第二章 字符串
    print("Hello Python world!")

    msg1 = "hi"
    print(msg1)

    msg2 = 'hi2'
    print(msg2)

    字符串连接

    msg3 = msg1 + ' ' + msg2
    print(msg3)

    ‘’和“”“”

    msg4 = "hello 'may' "
    print(msg4)

    msg5 = 'hello "may" '
    print(msg5)

    name = "ada lovelace"

    首字符大写

    print(name.title())

    全部大写

    print(name.upper())

    全部小写

    print(name.lower())

    制表符

    print("\tPython")

    换行符

    print("\nPython")

    fav_language = ' python '
    print(fav_language)

    去除后面空白字符

    print(fav_language.rstrip())

    去除前面空白字符

    print(fav_language.lstrip())

    去除前后空白字符

    print(fav_language.strip())

    相关文章

      网友评论

          本文标题:2018-07-23 Chapter 2.1 Ablout St

          本文链接:https://www.haomeiwen.com/subject/vaudmftx.html