"""
----------------演示Python中字符串的拼接--------------
-使用加号“+”连接 !字符串!变量 和 !字符串! 字面量即可
----------------------注意的事项------------------------
-无法和非字符串类型进行拼接
"""
# 字符串字面量之间的拼接
print("大力" + "," + "快来gong!")
# 字符串字面量和字符串变量之间的拼接
name = "大力"
context = "快gong过来!"
time = 8
# TypeError: can only concatenate str (not "int") to str
# print(name + ":" + context + "---" + time + "Am")
print(name + ":" + context + "---" + str(time) + "Am")
输出:
大力,快来gong!
大力:快gong过来!---8Am