Drkcore

04 04 2011 perl Python Tweet

pythonのsplit

splitの第二引数を与えると分割数を指定できる

>>> "test.tar.gz".rsplit('.')
['test', 'tar', 'gz']
>>> "test.tar.gz".rsplit('.',1)
['test.tar', 'gz']

perlだとこんな感じか(re.plで確認)

$ split /\./, "test.tar.gz"
$VAR1 = 'test';
$VAR2 = 'tar';
$VAR3 = 'gz';
$ split /\./, "test.tar.gz", 2
$VAR1 = 'test';
$VAR2 = 'tar.gz';

perlでrsplit相当のことやるにはどうすんだろか?

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021