版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
在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='')