May 29, 2021 Article blog
Using Python process occasionally encounter the need to stitch characters, today's small editor to share with you five commonly used methods, I believe that after reading can solve everyone Python how to stitch strings of doubt.
The first is
+
using the plus sign:
print('Love'+'Python')
The output is LovePython
The second uses
,
number to implement:
print('Love','Python')
The output is Love Python
The third is the first deformation, and the absence of spaces between characters does not affect the output:
print('Love''Python')
The output is LovePython
The fourth way to format:
print('%s %s' % ('Love', 'Python'))
The output is Love Python
The fifth way is to use
join
to stitch.
str_list = ['Love', 'Python']
print(''.join(str_list))
The output is LovePython
How does Python stitch strings? Here we are, if there are other questions you can move the W3Cschool website to learn.