Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                                                                                            
                
        
如何在没有特定索引的元素的情况下获取列表中的所有元素
   在python列表中。
   如果有一种快速简便的方法,那就太好了。

谢谢

最佳答案

假设

elements  # list of values
n  # unwanted element index


那你就可以

result = elements[:n] + elements[n+1:]


要么

result = elements[:]  # copy
del result[n]

关于python - 如何获取列表中的所有元素而在python中的特定索引处没有元素? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19446765/

10-11 22:09
查看更多