如何在python中将ascii值列表转换为字符串? [英] How do I convert a list of ascii values to a string in python?
本文介绍了如何在python中将ascii值列表转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Python程序中有一个列表,其中包含一系列数字,这些数字本身就是ASCII值.如何将其转换为可以在屏幕上回显的常规"字符串?
I've got a list in a Python program that contains a series of numbers, which are themselves ASCII values. How do I convert this into a "regular" string that I can echo to the screen?
推荐答案
您可能正在寻找'chr()':
You are probably looking for 'chr()':
>>> L = [104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100]
>>> ''.join(chr(i) for i in L)
'hello, world'
这篇关于如何在python中将ascii值列表转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文