Python pop(0) は Perl で言うところの shift¶
$ python Python 3.5.2 (default, Jun 28 2016, 08:46:01) [GCC 6.1.1 20160602] on linux Type "help", "copyright", "credits" or "license" for more information. >>> l = [ 100, 200, 300 ] # 引数なしは pop(-1) と同義 >>> l.pop() 300 >>> l [100, 200] # 引数に先頭要素を設定すれば Perl で言うところの shift >>> l.pop(0) 100 >>> l [200]
Last modified: 2016-12-19 | ||
|
||
|
||
© Shin Nakamura/BasicWerk 2008 - 2024 |