欢迎来到 StringLength.org

您的在线工具,用于即时计算任何字符串的长度。

选择您的语言:
不同语言的代码示例:
            
            // Python
            str = "Hello, world!"
            length = len(str)

            // JavaScript
            var str = "Hello, world!";
            var length = str.length;

            // Java
            String str = "Hello, world!";
            int length = str.length();

            // C++
            #include <string>
            std::string str = "Hello, world!";
            int length = str.length();

            // C#
            string str = "Hello, world!";
            int length = str.Length;

            // Ruby
            str = "Hello, world!"
            length = str.length

            // PHP
            $str = "Hello, world!";
            $length = strlen($str);

            // Swift
            let str = "Hello, world!"
            let length = str.count

            // Go
            import "unicode/utf8"
            str := "Hello, world!"
            length := utf8.RuneCountInString(str)

            // Rust
            let str = "Hello, world!";
            let length = str.len();