在Python 2.7中使用for进行水平打印
我对python有一些问题,我无法解决。当用户输入一个单词时,我想打印一个单词的重复,然后他会告诉我这个单词将重复多少次。顺便说一句,我不能。这里是到目前为止的代码在Python 2.7中使用for进行水平打印,python,python-2.7,Python,Python 2.7,我对python有一些问题,我无法解决。当用户输入一个单词时,我想打印一个单词的重复,然后他会告诉我这个单词将重复多少次。顺便说一句,我不能。这里是到目前为止的代码 b = raw_input 'enter word' c = input 'enter the amount of time the word will repeat' for g in range (c) print (b) 就像你们看到的,你们可以看到输入的重复,但在垂直线上,我怎么能水平打印呢 这是你的做法 imp
b = raw_input 'enter word'
c = input 'enter the amount of time the word will repeat'
for g in range (c)
print (b)
就像你们看到的,你们可以看到输入的重复,但在垂直线上,我怎么能水平打印呢 这是你的做法
import sys
b = raw_input('enter word')
c = input('enter the amount of time the word will repeat')
for g in range (c):
sys.stdout.write(b)
很简单。只需添加逗号
print (b),
因此,您的代码变成:
b = raw_input('enter word: ')
c = input('enter the amount of time the word will repeat: ')
for g in range (c):
print b,
可能重复的