将字符串列表转换为空格分隔的字符串 [英] Convert list of strings to space-separated string

查看:51
本文介绍了将字符串列表转换为空格分隔的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下划线表示未知单词的长度.如何只打印下划线而没有代表列表的括号?

I am using underscores to represent the length of a unknown word. How can I print just the underscores without the brackets that represent the list?

基本上,如果我有一个格式为 ['_','_','_','_'] 的列表,我想打印下划线而不用列表语法打印它们为"_ _ _ _"

Basically, if I have a list of the form ['_', '_', '_', '_'], I want to print the underscores without printing them in list syntax as "_ _ _ _"

推荐答案

这对您有用吗

>>> my_dashes = ['_', '_', '_', '_']
>>> print ''.join(my_dashes)
____
>>> print ' '.join(my_dashes)
_ _ _ _

这篇关于将字符串列表转换为空格分隔的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆