Python has two functions .join() and os.path.join(), which do the following:

. join(): Concatenate string arrays. Concatenates the elements of a string, a tuple, and a list with the specified characters (separator) to generate a new string

os.path.join(): Combine multiple paths and return

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

>>#Operate on sequences (using ' ', ' - ' and ':' as separators respectively)

>> a=['1','2','3','4','5']

>> '  '.join(a)

1 2 3 4 5

>>';'.jion(a)

1-2-3-4-5

>>'.'.join(a)

1.2.3.4.5

>>#Operate on strings (using ' ', ' - ' and ':' as separators respectively)

>>b='hello world'

>> '  '.join(b)

h e l l o   w o r l d

>>'-' .join(b)

h-e-l-l-o- -w-o-r-l-d

>>':'.jion(b)

h:e:l:l:o: :w:o:r:l:d

>>#Operate on tuples (using ' ', ' - ' and ':' as separators respectively)

>>c=('1','2','3','4','5')

>>'  '.join(c)

1 2 3 4 5

>>'-'.join(c)

1-2-3-4-5

>>':'.join(c)

1:2:3:4:5

>>#Unordered operation on dictionaries (using ' ', ' - ' and ':' as separators respectively)

>>d={'name1':'a','name2':'b','name3':'c','name4':'d'}

>>'  '.join(d)

name1 name2 name3 name4

>>'-'.join(d)

name1-name2-name3-name4

>>':'.join(d)

name1:name2:name3:name4

>>#Performing operations on directories

>> import os

>>os.path.join('/hello/','good/date','datbody')

hello/good/date/datbody

Related articles

Add new content to the python dict

Adding new content to a dictionary is done by adding new key/value pairs, modifying or deleting existing key/value pairs as in the following examples

How to delete elements in python dict

clear() method is used to clear all the data in the dictionary, because it is an in-place operation, so it returns None (also can be interpreted as no return value)

python crawler how to get cookies

Cookie, refers to the data (usually encrypted) that some websites store on the user's local terminal in order to identify the user and perform session tracking. For example, some websites require login to access a page, before login, you want to grab the

How OpenCV tracks objects in video

Each frame of the video is a picture, tracking an object in the video, decomposition down, in fact, is to find that object in each frame of the picture.

How does FastAPI close the interface documentation?

FastApi comes with interface documentation, which saves us a lot of work when developing back-end interfaces. It automatically identifies the parameters of the interface based on your code and also generates a description of the interface based on your