string.capwords() 将每个单词首字母大写 代码: import string s = ' The quick brown fox jumped over the lazy dog. ' print s print string.capwords(s) 结果: The quick brown fox jumped over the lazy dog. The Quick Brown Fox Jumped Over The Lazy Dog. 请按任意键继续. . . string模…
js对象转string的函数 function obj2str(o){ var r = []; if(typeof o =="string") return """+o.replace(/(['"\])/g,"\$1").replace(/(n)/g,"\n").replace(/(r)/g,"\r").replace(/(t)/g,"\t")+""…
1.有时候需要把对象中的字段属性打印出来,下面用JS实现输出对象: function writeObj(obj) { var description = ""; for (var i in obj) { var property = obj[i]; description += i + " = " + property + "\n"; } alert(description); } 2.结果对象是object而无法查看该对象里面的内容,用下面的函…
在java doc里有 String[] java.lang.String.split(String regex) Splits this string around matches of the given regular expression. This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Tra…
原文地址:http://hi.baidu.com/baowup/blog/item/3a27465c86d71546faf2c066.html/cmtid/de1ef3f0de7554a0a40f52f7 , int n = npos);//删除pos开始的n个字符,返回修改后的字符串 string类的迭代器处理: string类提供了向前和向后遍历的迭代器iterator,迭代器提供了访问各个字符的语法,类似于指针操作,迭代器不检查范围.用string::iterator或string::co…