python3----连接字符串数组(join)
2018-01-11 20:07
295 查看
join 方法用于连接字符串数组
1 s = ['a', 'b', 'c', 'd'] 2 print(''.join(s)) 3 print('-'.join(s)) 4 5 results: 6 7 abcd 8 a-b-c-d
使用 % 连接多个变量
1 a = 'hello' 2 b = 'python' 3 c = 1 4 print('%s %s %s %s' % (a, b, c, s)) 5 6 results: 7 8 hello python 1 ['a', 'b', 'c', 'd']
相关文章推荐
- Join函数:将数组中的字符串连接为一个字符串
- Python join() 函数 连接字符串
- Python天天美味(7) - 连接字符串(join %)(转)
- 利用join连接数组中的所有字符串
- python拆分字符串(.split),以及连接字符串(.join)。
- Python 入门:字符串连接及join用法
- Python中字符串连接、删除数组中指定元素、记录脚本运行时间
- 列表连接成字符串(join)(python)
- JS字符串连接(数组连接):创建一次拷贝一次 (减少创建和拷贝) strArray.join (减少创建临时字符串+拷贝)
- Python连接字符串,join出现问题:python 'list' object has no attribute
- Python的字符串连接join和拆分split
- python 中字符串连接+、join、%替换三种效率问题
- JavaScript基础 join() 将数组连接成字符串 化零为整
- python join连接字符串Demo
- JavaScript基础 join() 将数组连接成字符串 化零为整
- Python_连接List与分割字符串_join&split
- python字符串连接方式(转)
- Python中尽量少用加号“+”连接字符串的原因
- Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- 小技巧:用Javascript数组处理多个字符串的连接问题