Python - 在同一行按顺序打印字母表

BB9*_*956 -1 python python-2.7 python-3.x

我试图在同一行上打印字母表中的所有大写字母,但我不断收到语法错误。

for c in range(0, 26):
    print(chr(ord('A', end '')+c))
Run Code Online (Sandbox Code Playgroud)

Eth*_*Bar 5

ord()接受单个字符,并将其转换为其 Unicode 代码点。它只需要一个参数。看来您打算拨打, end ''电话print()。这是更新后的代码:

for c in range(0, 26):
    print(chr(ord('A')+c), end='')
Run Code Online (Sandbox Code Playgroud)