简体   繁体   English

使用 python 在输入中插入的每个字符后打印一个带空格的单词

[英]Print a word with space after each character that was inserted in an input using python

I would like to print the result of a text or word that is digited at a input with space between every character/letter/number, how can i do it with python?我想打印在每个字符/字母/数字之间有空格的输入中数字化的文本或单词的结果,我该如何使用 python 来实现?

I did some searchs, but i only found the code for 2 or more characters...我做了一些搜索,但我只找到了 2 个或更多字符的代码......

As John said in the comments, you can use str.join for this:正如约翰在评论中所说,您可以为此使用str.join

>>> x = input()
Hello
>>> ' '.join(x)
'H e l l o'

If you mean to split text like this: 'lorem ipsum' to ['lorem','ipsum'] , you could use x = string.split() .如果您打算像这样拆分文本: 'lorem ipsum'['lorem','ipsum'] ,您可以使用x = string.split()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在每个单词后打印空格 - Print space after each word 在python中使用readline为正在读取的输入文件的每个单词打印出自己的行 - using readline in python to print out own line for each word of an input file that is being read Python3-在混合字符串中的每个单词之后留出空格 - Python3 - Make space after each word in mixed string 在 python 中乘 n 次后每个字符之间添加空格 - Add space between each character after it is multiplied n times in python python 中每个字符之间的空格 - Space between each character in python 使用Python打印字符,单词和行数 - Print out the character, word, and line amounts using Python 输入一个字符串并使用 NLP Python 将每个单词与给定的单词进行比较 - input a string and compare each word with a given word using NLP Python 在文本中查找输入词并打印“关联字符” - Find an Input word in a text and print the "associated Character" 在python中没有空格的每个字符后将输入字符串转换为列表 - Convert input String to List after each character without spaces in python 如何使用计数器计算表中插入记录的数量并打印使用 python 脚本运行的每个作业中插入记录的数量 - How to count number of inserted records in table using counter and print the count of inserted record in each job run using python script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM