0
我正在编写需要垂直打印字符串的代码。我该怎么做呢?我班上有人告诉我试试这个:python 2.7.6在使用循环时垂直打印字符串
string = raw_input ('Please enter a string. ')
while string() true:
print string().
我试过这个,但没有奏效。有任何想法吗?
我正在编写需要垂直打印字符串的代码。我该怎么做呢?我班上有人告诉我试试这个:python 2.7.6在使用循环时垂直打印字符串
string = raw_input ('Please enter a string. ')
while string() true:
print string().
我试过这个,但没有奏效。有任何想法吗?
如果你要打印一个新行的字符串的每个字符,你可以遍历字符串:
user_input = raw_input ('Please enter a string. ') # store the string if a variable
for c in user_input: # for each character 'c' in the input
print(c) # print it. The print function add a new line character at each call