When Python output, remove the square brackets and parentheses outside the list tuple

Here you can use the join() function

'x'.join(y), x can be any split character, and y is a list or tuple. Taking a list as an example, the quotation marks around each element in the list can be removed. At the same time, the character'x' is used as the separation mark between the elements and the outer brackets of the list can also be removed. The same is true for tuples.

a_list=['monday','tuesday','wednesday','thursday','friday','saturday','sunday']
print(' '.join(a_list))
print("\r")
b_tuple=('monday','tuesday','wednesday','thursday','friday','saturday','sunday')
print(' '.join(b_tuple))


Guess you like

Origin blog.csdn.net/wxy_csdn_world/article/details/80746870