Nov-28-2017, 10:30 PM
Hi,
summary:
I have this output: [(1,), (2,), (3,), (4,), (5,)]
Question, how can I transform this to: ('1', '2','3','4',5')
Below is my trial
try 1:
Can somebody help me to transform the original [(1,), (2,), (3,), (4,), (5,)] into ('1', '2','3','4',5') ?
summary:
I have this output: [(1,), (2,), (3,), (4,), (5,)]
Question, how can I transform this to: ('1', '2','3','4',5')
Below is my trial
sId = cur1.fetchall() print(sId)
Output:[(1,), (2,), (3,), (4,), (5,)]
Here I change everything to an integer listsId = cur1.fetchall() sId2 = [x[0] for x in sId] print(sId2)
Output:[1, 2, 3, 4, 5]
Then I try to make it a stringtry 1:
sId = cur1.fetchall() sId2 = [x[0] for x in sId] sId2 = tuple(sId2) print(sId2)
Output:(1,2,3,4,5)
try 2:sId = cur1.fetchall() sId2 = [x[0] for x in sId] sId2 = (",".join(str(i) for i in sId2)) print(sId2)
Output:1,2,3,4,5
Not yet what I need...Can somebody help me to transform the original [(1,), (2,), (3,), (4,), (5,)] into ('1', '2','3','4',5') ?