python turns list into a string with a symbol separated method in the middle

  • 2020-12-26 05:47:42
  • OfStack

As shown below:


data = [1,2,3,4]
print "|".join(str(i) for i in data)

If data has Chinese:


import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )

Related articles: