1

Below is what Im getting when I print

executionId = str(thread_ts)

print (executionId) 

Output:

('1608571839.008600',)

How can I just get the value without ('',) i.e 1608571839.008600

Rk5
  • 325
  • 1
  • 4
  • 17

1 Answers1

2

I'm guessing thread_ts is a tuple?

>>> str((1608571839.008600,))

'(1608571839.008600,)'

So either index the value:

thread_ts = (1608571839.008600,)
executionId = thread_ts[0] 
print(executionId) # or print(str(executionId))

Or unpack:

thread_ts = (1608571839.008600,)
executionId = thread_ts
print(*executionId) # or print(str(*executionId))

I add the str calls if you actually wanted to explicitly convert to str type, but for printing numbers that is not really necessary.

Also, note the difference between the two approaches. In the first example, executionId is a number executionId ---> 1608571839.008600, while in the second, executionId is still a tuple executionId ---> (1608571839.008600,)

Tom
  • 8,310
  • 2
  • 16
  • 36