Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 chr() 在一行上打印字母,每个字母用空格分隔。
我当前的代码:
for x in range(97,123): letter = chr(x) alphabet = "" + letter print alphabet
import string print " ".join(string.lowercase)
或者,如果使用chr是强制性的,如评论中所述:
chr
print " ".join([chr(c) for c in xrange(ord('a'), ord('z') + 1)])
使用,afterprint语句,以便
,
print
print alphabet,