立即学习:https://edu.csdn.net/course/play/26755/340111?utm_source=blogtoedu
字符串和字符串连接的方法:
1.加号连接:
s = "hello" + "python" + "world"
2.直接连接:
s = "hello""python""world"
3.逗号连接:
print("hello", "python", "world")
4.格式化:
s = "<%s> <%s> <%s>" % ("hello","python", "world")
5.join连接:
s = "".join(["hello", "python", "world"])
字符串与非字符串连接的方法:
1.加号:
s = "hello" + str(n) #n不等于字符串
2.格式化:
s = "<%s> <%d> <%f>" % ("hello", 243, 23.465)