shuffle string in python

后端 未结 4 2137
春和景丽
春和景丽 2020-11-27 17:59

I am looking for a function or short program that receives a string (up to 10 letters) and shuffles it.

4条回答
  •  清歌不尽
    2020-11-27 18:33

    >>> import random
    >>> s="abcdef123"
    >>> ''.join(random.sample(s,len(s)))
    '1f2bde3ac'
    

提交回复
热议问题