List的所有元素求和
a=[1,2,3]
result=sum(a)
在List头部插入元素
思想:将你想要插入的头部元素先append到尾部,然后对list进行反转
theList=[1,2,3]
a=4
theList.append(a)
theList.reverse()
a=[1,2,3]
result=sum(a)
思想:将你想要插入的头部元素先append到尾部,然后对list进行反转
theList=[1,2,3]
a=4
theList.append(a)
theList.reverse()
本文标题:Python List
本文链接:https://www.haomeiwen.com/subject/phptwctx.html
网友评论