字符串和其他类型转换
功能 | 函数 |
---|---|
字符串str转换成int | int_value = int(str_value) |
int转换成字符串str | str_value = str(int_value) |
int -> unicode | unicode(int_value) |
unicode -> int | int(unicode_value) |
str -> unicode | unicode(str_value) |
unicode -> str | str(unicode_value) |
int -> str | str(int_value) |
str -> int | int(str_value) |
替换
a = 'hello word'
a.replace('word','python')
输出的结果是hello python
分割
print a.split('|')