如何打印没有括号、逗号和引号的整数列表? [英] How to print a list with integers without the brackets, commas and no quotes?
本文介绍了如何打印没有括号、逗号和引号的整数列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是一个整数列表,这是它们的打印方式:
This is a list of Integers and this is how they are printing:
[7, 7, 7, 7]
我希望他们像这样简单地打印:
I want them to simply print like this:
7777
我不想要括号、逗号或引号.怎么办?
I don't want brackets, commas or quotes. What to do?
推荐答案
如果您使用的是 Python 3 或带有 from __future__ import print_function
的适当 Python 2.x 版本,则:
If you're using Python 3, or appropriate Python 2.x version with from __future__ import print_function
then:
data = [7, 7, 7, 7]
print(*data, sep='')
否则,您需要转换为字符串并打印:
Otherwise, you'll need to convert to string and print:
print ''.join(map(str, data))
这篇关于如何打印没有括号、逗号和引号的整数列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文