Python Programming: List

Python – , , , . – . Python (, , , ) . – .

, . . Turbo Pascal Delphi. .

python list




, Python : , , . . .

. ?

. . FOR.

python file list




Python . list . , .





python list to string




, . Python FOR. , . . .

Python , . . :

  • List1.append (x) – , .
  • List1.extened (list2) – list2 list1. , extend .
  • List1.insert (i,x) – i. , ( , append), .
  • List1.remove (x) – . , . , ValueError (x not in list).
  • List1.pop ([i]) – i. , . , , . . .

python 3 lists








  • List1.index (x, [start], [end]) – start end. . , 0. . . 0, – 1 . . , = [1.78487,5.575,7.364]. [0] = 1.78487, [1] = 5.575, [2] = 7.364.
  • List1.count (x) – , . , , .
  • List1.sort ([key = ]) – . Python . , .
  • List1.reverse () – , . . , . .
  • List1.copy () – .

? .

:

  • Print – . Python 2.7 , Python 3 . , Python 2.7 : print « », kolichestvo ( -, – ). Python 3 : print (« », kolichestvo). .
  • Len(list1) – Python .
  • Min – , , .

python sort list




  • Max – .
  • Sum – , , . , TypeError: unsupported operand type(s) for +: 'int' and 'str'.
  • Help – . help (int) – , help (str) – , help (file) – , , , .
  • Type – , . : >>> text_str = «» >>> type (text_str) >>> <type 'str'>
  • in. , , .

. , Python . Turbo Pascal Delphi, , Python 3-4 .

python list generator




, Python , immutable. , tuple. . . tuple . , – . . append, . , tuple.

python list length




tuple , . : tuple ("string") → ("s","t","r","i","n","g").

, Python . OS listdir. , Python 3 ( 2.7 ) os.listdir (path) path . .

python file list




1. . , . . . .

:

  • List1 (. . ).
  • .
  • , , , (min<X<max).
  • List2.
  • List2 .

python list




2. . , , , .

:

  • .
  • , .
  • , « ».
  • .

  • 1. , . : while, len ().
  • . , (, ). , , – , – .
  • . . , , 0.

python list




  • . . , . . 2. : FOR. : , .
  • . . . , .




All Articles