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

3
  • 3
    executionId[0] Commented Dec 21, 2020 at 17:59
  • 2
    @jakub executionId[0] would be the character '('. Commented Dec 21, 2020 at 18:12
  • oops, thanks. that should be thread_ts[0] as the accepted answer shows. Commented Dec 21, 2020 at 20:24

1 Answer 1

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,)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.