B
B
beduin012018-04-28 16:11:43
Python
beduin01, 2018-04-28 16:11:43

How to convert list to string?

You need to convert list to a string.

for row in data_body:
  print(row)
  data = ','.join(row)

However, the following error is thrown. I can't figure out why:
[None, u'1516482864.000000', 627, 0, u'9227943', 41, 60.0, u'transaction', u'+345348880', u'5000.00', u'345188435', 472, 1463, u'2018-01-20 21:12:19.019598', u'6be2d345dd43af6fc23', 6225064, u'222222222']
Traceback (most recent call last):
  File "app.py", line 72, in <module>
    data = ','.join(row)
TypeError: sequence item 0: expected string, NoneType found

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-04-28
@beduin01

data = ','.join(str(i) for i in row)
if None should be removed

data = ','.join(str(i) for i in row if i is not None)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question