获取字符串长度

输出结果

5


程式码


JavaScript

let str = "A-B-C";
console.log(str.length);

Perl

my $str = "A-B-C";
print length($str)."\n";

PHP

<?php
$str = "A-B-C";
print strlen($str)."\n";

Python

example = "A-B-C"
print(str(len(example)))

Ruby

str = "A-B-C";
print(str.length.to_s + "\n")