python is used join () method

Use join () method of various types of data are combined Meta prime splice

"Connector" .join (or tuples or string list or dictionary)

  • Using the returned string is a connector for splicing

  • If the object is a list, a tuple, it is next to a standard element as a unit for splicing

  • If the object is a string, that is a word element stitching units

  • If the object is a dictionary, it is a key to the unit of stitching

List

In [4]: a = ["123", "123"]

In [5]: b = "".join(a)

In [6]: b
Out[6]: '123123'

PS: I encountered a problem no one answer? Requires Python learning materials? Click on the link below you can add yourself get
note.youdao.com/noteshare?id=2dce86d0c2588ae7c0a88bee34324d76

dictionary

In [14]: a = {"fdasd":"adsf","afdasdf":"asdf"}

In [15]: b = "".join(a)

In [16]: b
Out[16]: 'fdasdafdasdf'

String

In [17]: a= "asdfadsf"

In [18]: b = "+".join(a)

In [19]: b
Out[19]: 'a+s+d+f+a+d+s+f'

Guess you like

Origin www.cnblogs.com/xxpythonxx/p/12093479.html