日期:2023年3月3日
作者:Commas
签名:(ง •_•)ง 积跬步以致千里,积小流以成江海……
注释:如果您觉得有所帮助,帮忙点个赞,也可以关注我,我们一起成长;如果有不对的地方,还望各位大佬不吝赐教,谢谢^ - ^
1.01365 = 37.7834;0.99365 = 0.0255
1.02365 = 1377.4083;0.98365 = 0.0006

前言:
在Python中,你可以使用以下5种不同的方法来拼接字符串。
str1 = "Hello"
str2 = "World"
result = str1 + " " + str2
print(result) # 输出:Hello World
str_list = ["Hello", "World"]
result = " ".join(str_list)
print(result) # 输出:Hello World
温馨提示:Python 3.6及更高版本。
str1 = "Hello"
str2 = "World"
result = f"{str1} {str2}"
print(result) # 输出:Hello World
str1 = "Hello"
str2 = "World"
result = "{} {}".format(str1, str2)
print(result) # 输出:Hello World
温馨提示:不推荐,Python 3.6之后,推荐使用f-字符串或字符串格式化。
str1 = "Hello"
str2 = "World"
result = "%s %s" % (str1, str2)
print(result) # 输出:Hello World
版权声明:本文为博主原创文章,如需转载,请给出:
原文链接:https://blog.csdn.net/qq_35844043/article/details/134009776