name = "my \tname is {name} and i am {year} old" capitalize:第一个单词的首字母大写的方法 print(name.capitalize()) count:统计字母的个数 print(name.count("a")) center:打印多少个字符 print(name.center(50,"-")) endswith:判断一个字符串什么结尾 print(name.endswith("…
1.去空格 strip() >>> s = 'a b c d ' >>> s.strip() 'a b c d' 2.lstrip() 方法用于截掉字符串左边的空格或指定字符 #!/usr/bin/python str = " this is string example!" print str.lstrip() str = "99999this is string example!888888" ') 以上实例输出结果如下: $…
一.charAt() 返回在指定位置的字符. var str="abc" console.log(str.charAt(0))//a 二.charCodeAt() 返回在指定的位置的字符的 Unicode 编码. var str="abc" console.log(str.charCodeAt(1))//98 三.concat() 连接字符串. var a = "abc"; var b = "def"; var c = a.c…
原文链接:http://caibaojian.com/js-string.html 一.charAt() 返回在指定位置的字符. var str="abc" console.log(str.charAt(0))//a 二.charCodeAt() 返回在指定的位置的字符的 Unicode 编码. var str="abc" console.log(str.charCodeAt(1))//98 三.concat() 连接字符串. var a = "abc&q…