this article illustrates that Python decomposes element operations from any Iterable object of any length. Share to you for your reference, as follows:

decomposition of N elements from a iterables, but iterables length can be more than N, there will be "abnormal decomposition value too much";

"* < / span> expression" to solve the question:

 Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 242015, 22:43:06 32) [MSC v.1600 bit (Intel)] on Win32 Type "copyright", "credits" or "license (more) for information. > > > * headdata, current=[10,3,2,6,8,5] #* modified variables in the list in the first place, easy head respectively. And the tail of > > > headdata [10, 3, 2, 6, 8] > > > current 5 > > > record= ('dave','dave@example.com','773-555-1212','847-555-1212') > > > name, email, *phone_numb Ers=record#* modified variables in the list last position > > > name'dave'> > > email'dave@example.com' > > > phone_numbers ['773-555-1212','847-555-1212'] > > > line='nobody:*: -2:-3:Unpriviledged User:/var/empty:/usr/bin/false' > > > uname, *fields, homedir, sh=line.split (':') #* modified variable is in the middle position, and string manipulation combined with > > > uname'nobody'> > > homedir;'/var/empty' & gt; > > SH'/usr/bin/false'> > > fields ['*','-2','-3','Unpriviledged User'] > > > record=['lucy', 50123.4 and (12,132016)] > > > name, *_, (*_, year) =record # some decomposition value of discarded > > > name'lucy' > > > year 2016 > > > 

type

* A variable iteration method in long sequences of tuples are particularly useful when:

></p>
<p>

(code "Python Cookbook")

more Python on the relevant content of interested readers can see the special station: "Python data structure and algorithm tutorial ," "Python ", summarizes the skills in the use of function "Python " string operation skills summary, "Python entry and advanced tutorial classic " and "Python file and directory operation skills"

summary of the hope for all Python programming help.

you might be interested in this article:

realization method


This concludes the body part

This paper fixed link:http://www.script-home.com/python-cookbook-data-structure-and-algorithm-decomposition-of-element-operations-from-an-arbitrary-length-of-iterable-object.html | Script Home | +Copy Link

Article reprint please specify:Python Cookbook (data structure and algorithm) decomposition of element operations from an arbitrary length of Iterable object | Script Home

You may also be interested in these articles!