함수 rjust()

1 개요[ | ]

함수 rjust()
함수 leading_space()
CLI align right
  • Example: "Hi", 4 → " Hi"

2 JavaScript[ | ]

s = 'Hi'
console.log( s.padStart(4, ' ') ) // "  Hi"
values = [1, 42, 1004, 'abc', 'hello'];
for( i in values ) {
  console.log( values[i].toString().padStart(6, ' ') );
}

3 PHP[ | ]

$str = 'Hi';
$spaced_str = str_pad($str, 4, ' ', STR_PAD_LEFT);
var_dump( $spaced_str );
$values = [1, 42, 1004, 'abc', 'hello'];
foreach( $values as $value ) {
  echo str_pad($value, 6, ' ', STR_PAD_LEFT),"\n"; 
}

4 Python[ | ]

values = (1, 42, 1004, 'abc', 'hello')
for value in values:
    print( str(value).rjust(6) )

5 Perl[ | ]

my @values = (1, 42, 1004, 'abc', 'hello');
foreach my $value (@values) {
	printf("%6s\n",$value);
}

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}