At that time, after reading the basic syntax of Python to a friend wrote a dollar probability conversion after the stitching results found that do not know how Python splicing strings to see some of the information they made a summary
The first is the same way that JavaScript is stitched together.
Name = input ("Name:") Age= Input ('Age :') Job= Input ('Job:') Str="""------string concatenation------"""+"""Name"""+name+"""Age"""+age+"""Job"""+jobprint (str)
Multi-memory is not recommended via plus stitching
The second is through placeholder stitching recommendations
Name = input ("name:"= input ('age:'= input ( ' Job: ' "' -------string concatenation ------- Name:% s Age :%D Job:%D' ' % (name,int (age), int (Job))print (str)
The%s in the string represents the character type%d, which means that the number type is in% () passed in must type corresponds or the other type is not more descriptive.
The third way to call the Format method by string is to recommend
Name = input ("name:"= input ('age:'= input ( ' Job: ' "' -------info of {_name}------- name:{_name} age:{_age} job:{_ Job}' . Format (_name = name , _age = Age,_job = job) print (str)
The result is the same as above
A variable defined within a string is assigned to it in format.
Format can also be used to recommend
Name = input ("Name:") Age= Input ('Age :') Job= Input ('Job:') STR3=" "-------Hello Word {0} -------name:{0} age:{1} job:{2}" ". Format (name,age,job)print (STR3)
It is necessary to use the order to get the subscript to be passed.
About string concatenation that's it. Friendship Reminder in Python forget the plus sign splicing very low performance
Several methods of Python string concatenation