我有一组字符串,例如:
my_prefix_what_ever
my_prefix_what_so_ever
my_prefix_doesnt_matter
我只想找到这些字符串的最长公共部分,这里是前缀。在上面的例子中,结果应该是
my_prefix_
这些字符串
my_prefix_what_ever
my_prefix_what_so_ever
my_doesnt_matter
应该产生前缀
my_
在Python中有没有一种相对轻松的方法来确定前缀(不必手动迭代每个字符)?
附注:我正在使用Python 2.6.3。