雪梨任务python-1
雪梨任务python-1
- Python返回数组长度 ,len(数组名)
- not supported between instances of ‘NoneType’ and ‘int’ 可能是符号右边出现了问题
- Python删除数组元素 数组名.remove(‘字符’) del 数组名【索引】
- ** “”.join() 出错TypeError: sequence item 0: expected string, int found
** 改为’,’.join(’%s’ % id for id in ls)即可成功 -
int(x [,base ]) 将x转换为一个整数
long(x [,base ]) 将x转换为一个长整数
float(x ) 将x转换到一个浮点数
complex(real [,imag ]) 创建一个复数
str(x ) 将对象 x 转换为字符串
repr(x ) 将对象 x 转换为表达式字符串
eval(str ) 用来计算在字符串中的有效Python表达式,并返回一个对象
tuple(s ) 将序列 s 转换为一个元组
list(s ) 将序列 s 转换为一个列表
chr(x ) 将一个整数转换为一个字符
unichr(x ) 将一个整数转换为Unicode字符
ord(x ) 将一个字符转换为它的整数值
hex(x ) 将一个整数转换为一个十六进制字符串
oct(x ) 将一个整数转换为一个八进制字符串 - python字符串拼接
print("haha%d"%(13)) //正确
print("haha"+13) //报错can only concatenate str (not "int") to str
- 字符串拼接的7中方法 ;
- 字符串方法(find、index)
- 字符串指定位置插入字符
b=list(b)//先转换为数组
b.insert(b.index(i)+1,index)//选择位置插入
b="".join('%s' % id for id in b)//转化为字符串
用markdown的第一天爱鹿晗❤