Python string stitching In the actual development of Python, many need to use string splicing, there are a lot of string splicing in Python, sum up today: Splicing with + symbol Stitch with % symbol Stitching with join() Splicing with the format() method Use the Template object in the string module Fruit1 = 'apples' Claim: Use + to splic the string as follows: This method is relatively inefficient and is not recommended. The method of splicing with % symbol is as follows: In addition to the tuple method, you can also use the dictionary as follows: Join()` method is stitched as follows This method uses sequence operations Use the format() method to splicing as follows: You can also specify the location of the parameter: Similarly, you can also use a dictionary: Use the Template object in the string module as follows: to sum up There are many ways to splicing. Different methods are used in different occasions. Individuals recommend % and format() methods, which are simple and convenient. Spinner Rotary Joint,Fiber Optic Rotary Joint,Rotary Union,Coaxial Rotary Joint Dongguan Oubaibo Technology Co., Ltd. , https://www.sliprob.com
Fruit2 = 'bananas'
Fruit3 = 'pears'
Output string 'There are apples, bananas, pears on the table'