python-字符串拼接

1. python-字符串拼接

  • 使用 “+” 可以对多个字符串进行拼接。

  • 示例:

    str1 = "hello"
    str2 = "world"
    print(str1 + str2)
    
  • 其他方式:

    • 格式化输出
    • 逗号
    • join() 内建函数,将序列中的元素拼接成一个字符串。后面讲到

2. 案例

  • 案例1、字符串拼接

    #!/usr/bin/env python3
    # _*_ coding: utf-8 _*_
    # Author:shichao
    # File: .py
    
    str1 = "hello"
    str2 = "world"
    print(str1 + str2)
    
posted @ 2022-12-26 11:29  七月流星雨  阅读(99)  评论(0编辑  收藏  举报