python中print输出一行,如果想多次输出的内容不换行,可以在print后面加逗号

例如

每个输出一行

phrase = "abcdefg"
# Add your for loop
for char in phrase:
        print char
a
b
c
d
e
f
g

 

输出在同一行

phrase = "A bird in the hand..."

# Add your for loop
for char in phrase:
    if(char == "A" or char == 'a'):
        print 'X',
    else:
        print char,
#Don't delete this print statement!
print
X   b i r d   i n   t h e   h X n d . . .

 



相关文章:

  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
相关资源
相似解决方案