我有一组字符串,例如
my_prefix_what_ever
my_prefix_what_so_ever
my_prefix_doesnt_matter
Run Code Online (Sandbox Code Playgroud)
我只是想找到这些字符串中最长的公共部分,这里是前缀.在上面的结果应该是
my_prefix_
Run Code Online (Sandbox Code Playgroud)
字符串
my_prefix_what_ever
my_prefix_what_so_ever
my_doesnt_matter
Run Code Online (Sandbox Code Playgroud)
应该导致前缀
my_
Run Code Online (Sandbox Code Playgroud)
在Python中有一种相对无痛的方法来确定前缀(无需手动迭代每个字符)吗?
PS:我使用的是Python 2.6.3.