1. 首页
  2. 数据库
  3. 其它
  4. Python 连接字符串(join %)

Python 连接字符串(join %)

上传者: 2020-12-31 16:37:22上传 PDF文件 27.62KB 热度 34次
join 方法用于连接字符串数组 复制代码 代码如下:s = [‘a’, ‘b’, ‘c’, ‘d’] print ”.join(s) print ‘-‘.join(s) 输出结果: abcd a-b-c-d 使用 % 连接多个变量 复制代码 代码如下:a = ‘hello’ b = ‘python’ c = 1 print ‘%s %s %s %s’ % (a, b, c, s) 输出结果: hello python 1 [‘a’, ‘b’, ‘c’, ‘d’] 您可能感兴趣的文章:python 将列表中的字符串连接成一个长路径的方法Pyth
下载地址
用户评论