python中字符串方法 name = "I teased at life as if it were a foolish game" print(name.capitalize())#首字母大写 print(name.count("a"))#查找字符串中a的个数 print(name.center(50,"-"))#长度为50将name放中间不够的用-补全 print(name.endswith("ex"))#字符串是否以e
1.列表 # Filename: using_list.py # This is my shopping list shoplist=["apple", "mango", "carrot", "banana"] print ("I have", len(shoplist), "items to purchase.") print ("These items are:"
Javascript 的数组Array,既是一个数组,也是一个字典(Dictionary). 先举例看看数组的用法. var a = new Array(); a[0] = "Acer"; a[1] = "Dell"; for (var i in a) { alert(i); } 上面的代码创立了一个数组,每个元素都是一个字符串对象. 然后对数组进行遍历.注意 i 的结果为 0 和 1,a[i] 的结果才为字符串. 这个很象上一篇中说到的遍历对象的属性. 下面再看一
Javascript 的数组Array,既是一个数组,也是一个字典(Dictionary). 先举例看看数组的用法. var a = new Array(); a[0] = "Acer"; a[1] = "Dell"; for (var i in a) { alert(i); } 上面的代码创立了一个数组,每个元素都是一个字符串对象. 然后对数组进行遍历.注意 i 的结果为 0 和 1,a[i] 的结果才为字符串. 这个很象上一篇中说到的遍历对