python3.0 怎么输出到一行上

在print()括号内要输出的参数后面加上end,只后加上你要的间隔符,如:

phrase = "A bird in the hand..."
for char in phrase:
    if(char == "A" or char == 'a'):
        print ('X')
    else:
        print (char')

在这里插入图片描述

phrase = "A bird in the hand..."
for char in phrase:
    if(char == "A" or char == 'a'):
        print ('X',end='')
    else:
        print (char,end='')

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_38970783/article/details/84071240