html的基本数据类型(数字,字符串, 列表, 字典)

基本数据类型

1. 数字

a = 18 ; 

2. 字符串

a = 'alex'
a.chartAt(索引位置)
a.substring(起始位置, 借宿位置)
a.length 获取当前字符串长度
a.trim 去除空白
a.concat(123) 拼接
a.indexof(8) 获得子序列的位置
a.lastIndexof(1)
a.slice(start, end)
a.toLowercase() 大写
a.toUpperCase() 小写
a.split('e')
a.split('e', 1)

3. 列表(数组)

a = [11, 22, 33]
a.length
a.push 尾部追加元素
a.pop() 去除尾部的最后一个元素
a.unshift 头部插入数据
a.shift 头部去除数据
a.splice(1, 2, 333) 1表示位置, 2表示删除个数, 333 表示插入位置
a.slice 切片
a.reverse() 反转
a.join('-') 将数组元素连接起来构建一个字符串
a.concat() 连接数组
a.sort() 进行排序

4.字典

a = {'k1': 'v1', 'k2': 'v2'}

原文地址:https://www.cnblogs.com/my-love-is-python/p/9291564.html