How to concatenate strings in python
In this article, the editor introduces in detail "how to concatenate strings in python". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to splice strings in python" can help you solve your doubts.
There are several ways to concatenate strings in python
1. Direct connection string
Print ('heelo'' world')
Print ('heelo''world')
two。 Use the plus sign to connect the string
> aPermie b = 'heelo','world'
> a + b
'heelo world'
3. Connect a string with a comma
> aPermie b = 'heelo','world'
Print (afort b)
> heelo world
4. Use% connection string
Print ('% s% s'% ('heelo','world'))
5. Use format connection string
Print ('{} {} '.format (' heelo','world'))
6. Use f-string to connect strings
> aa, bb = 'heelo','world'
> f' {aa} {bb}'
'heelo world'
7. Use the join method to connect a string
Print ('- '.join ([' aa','bb','cc']))
After reading this, the article "how to concatenate strings in python" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.