It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                7年前关闭。
            
                    
如果c = '32486784298'

然后'{0}{1}{2}.{3}{4}{5}.{6}{7}{8}-{9}{10}'.format(*c)

打印'324.867.842-98'

有最简单的方法吗?
(请没有定义)

最佳答案

在最新版本的Python中,您可以省略字符串格式占位符中的数字:

>>> '{}{}{}.{}{}{}.{}{}{}-{}{}'.format(*c)
'324.867.842-98'


它适用于Python 2.7。

08-06 12:37