. , .
, , . .
, . ; , , .
, . , , . , , .
, . .
. , 5 , ( ) int ( ) . , help(int) .
, . list . , append . , .append(' ') . .
, . / . , , .field.
(__.py ):
#
_ = ['', '', '', '']
print(' ', len(_), ' .')
print(' :', end=' ')
for in _:
print(, end=' ')
print('\n ')
_.append('')
print(' ', _)
print(' ')
_.sort()
print(' ', _)
print(' ', _[])
_ = _[]
del _[]
print(_, '')
print(' ', _)
:
$ python __.py
4 .
:
.
['', '', '', '', '']
['', '', '', '', '']
['', '', '', '']
. , , .
, for..in . , . .
, , print end .
, , append . , print print , .
, sort . , - . , .
, , . del . , , del . , del [0] ( 0- ) .
, help(list) .
. , . , , .
, .
( ) .
(__.py ):
#
# ;
# .
# .
= ('', '', '')
print(' ', len())
_ = '', '', # , .
print(' ', len(_))
print(' ', _)
print(' ', _[2])
print(' ', _[2][2])
print(' ',
len(_)-1+len(_[2]))
:
$ python __.py
3
3
('', '', ('', '', ''))
('', '', '')
5
. len . , .
, . , _ , . , .
, . . _[2] _ , _ _[2][2] . .
0 1
= () . , . ( ) , , . ,2 , = (2 , ) .
, . , , , . , , .
. . , () () . , .
( ) , . , .
d = {key1 : value1, key2 : value2 } . - , , .
- . , .
, dict / .
(__.py ):
# ''
= {
'': 'swaroop@swaroopch.com',
'': 'larry@wall.org',
'': 'matz@ruby-lang.org',
'': 'spammer@hotmail.com'
}
print(" ", [''])
#
del ['']
print('\n {} \n'.format(len()))
for , in .items():
print('{} {}'.format(, ))
#
[''] = 'guido@python.org'
if '' in :
print("\n ", [''])
:
$ python __.py
swaroop@swaroopch.com
3
swaroop@swaroopch.com
matz@ruby-lang.org
larry@wall.org
guido@python.org
. , , - . .
del - . , del . , .
, - , items . , for..in name address for- .
, , - .
- in ..
dict ,help(dict) .
, ! - - , , , ( ).
, , , ?
(, in not in ) .
, , , , .
(_.py ):
= ['', '', '', '']
= ''
# '' #
print(' ', [])
print(' 1 ', [1])
print(' 2 ', [2])
print(' 3 ', [3])
print(' -1 ', [-1])
print(' -2 ', [-2])
print(' ', [])
# #
print(' 1 3 ', [1:3])
print(' 2 ', [2:])
print(' 1 -1 ', [1:-1])
print(' ', [:])
# #
print(' 1 3 ', [1:3])
print(' 2 ', [2:])
print(' 1 -1 ', [1:-1])
print(' ', [:])
:
$ python _.py
1
2
3
-1
-2
1 3 ['', '']
2 ['', '']
1 -1 ['', '']
['', '', '', '']
1 3
2
1 -1
, . . , , . 0- . , [0] , [3] .
, , . , [-1] [-2] .
, (:) . . , .
( ) , ( ) . , . , . , , , .
, [1:3] 1- , 2- , 3- , . , [:] .
. . , [:-1] , .
, (, 1 ):
>>> = ['', '', '', '']
>>> [::1]
['', '', '', '']
>>> [::2]
['', '']
>>> [::3]
['', '']
>>> [::-1]
['', '', '', '']
2 , 0, 2, 4,... , 3 , 0, 3, 6, .
, . , , !
. , .
, , , , .
>>> = set(['', '', ''])
>>> '' in
True
>>> '' in
False
>>> = .copy()
>>> .add('')
>>> .issuperset()
True
>>> .remove('')
>>> & # OR bri.intersection(bric)
{'', ''}
, . , , " " " " .
, , , ! , , . , .
, , , :
(_.py ):
print(' ')
= ['', '', '', '']
# !
=
# ,
del []
print(' ', )
print(' ', )
# ''
# ;
#
print(' ')
#
= [:]
#
del []
print(' ', )
print(' ', )
#
:
$ python _.py
['', '', '']
['', '', '']
['', '', '']
['', '']
.
, ( ) , . , '''', .
. .
. ? , , ? , ... format !
str str. . , help(str) help(str).
(__.py ):
#
= ''
if .startswith(''):
print(', "" ')
if '' in :
print(', "" ')
if .find('') != -1:
print(', "" ')
= '_*_'
= ['', '', '', '']
print(.join())
:
$ python __.py
, ""
, ""
, ""
_*__*__*
, . startswith , . , in .
find , ; find -1 . str , , , join .
. .
, .