Create a tuple from a string and a list of strings

后端 未结 3 617
[愿得一人]
[愿得一人] 2021-01-03 23:56

I need to combine a string along with a list of strings into a tuple so I can use it as a dictionary key. This is going to be in an inner loop so speed is important.

<
3条回答
  •  甜味超标
    2021-01-04 00:54

    I can't speak for performance, but this is definitely the simplest I can think of:

    my_tuple = tuple([my_string] + my_list)
    

提交回复
热议问题