ice0724 发表于 2017-9-5 15:23:10

str1 = 'IloveFishC.com'
for i in str1:
   print(i)

ESON 发表于 2017-9-5 15:23:54

看看

schweinfan 发表于 2017-9-5 16:44:15

不自觉地就想用循环。。。

schweinfan 发表于 2017-9-5 17:12:06

sunnychou 发表于 2017-9-5 14:32
为什么在notebook上不加\n也换行尼

应该是因为print函数默认换行吧

Ruiksr 发表于 2017-9-5 17:24:22

for i in "IloveFishC.com":
      print(i)

Assistant 发表于 2017-9-5 19:46:20

冬雪雪冬 发表于 2017-9-4 19:12
如果函数可以接收多个参数,可以将一个可迭代对象在前面加上*分解为多个参数传入。
例如
fun(*)
...

BngThea 发表于 2017-9-5 20:03:24

回复学习一下

猫久 发表于 2017-9-5 20:06:28

66666666666666666

sige 发表于 2017-9-5 20:30:43

来个通俗易懂的{:9_241:}
print('将IloveFishC.com竖向打印')
print('------------------------')
str1 = 'IloveFishc.com'
for i in range(len(str1)):
    print(str1,end = '\n')

klykq111 发表于 2017-9-5 21:46:56

str1 = 'IloveFishC.com'
str2="\n".join(str1)
print(str2)

Greenland 发表于 2017-9-5 22:29:51

def verticalPrint(string):
    print('\n'.join(string))

古堡主人。 发表于 2017-9-6 10:09:38

本帖最后由 古堡主人。 于 2017-9-6 10:11 编辑

我就是想把特别复杂的东西写在一行上,为此一直在装b的路上……
str1 = 'IloveFishC.com'
print('\n'.join(str1))

misstaki 发表于 2017-9-6 14:00:01

{:10_256:}{:10_256:}{:10_266:}{:10_266:}{:10_269:}{:10_249:}{:10_261:}

pythonlaser 发表于 2017-9-6 15:22:02

工程狗 发表于 2017-9-5 08:56
str1 = 'IloveFishC.com'
n = 0
print(str1)


niubi!

qlm0216 发表于 2017-9-6 16:27:05

>>> str1 = 'IloveFishC.com'
>>> print(*str1,sep='\n')
I
l
o
v
e
F
i
s
h
C
.
c
o
m

编程新血 发表于 2017-9-6 19:17:17

我瞧瞧

编程新血 发表于 2017-9-6 19:24:04

str1 = 'IloveFishC.com'
print('I')
print('l')
print('o')
print('v')
print('e')
print('F')
print('i')
print('s')
print('h')
print('C')
print('.')
print('c')
print('o')
print('m')

####我没用循环

mintaka 发表于 2017-9-6 20:26:48

str1 = 'IloveFishC.com'
list=list(str1)
for str in list:
    print str

mintaka 发表于 2017-9-6 20:37:30

答案的语法是py3的吗,我用了报错SyntaxError: invalid syntax
{:10_243:}

Kuroi幻月 发表于 2017-9-6 22:15:38

str1 = 'IloveFishC.com'
print("\n".join(str1))
页: 1 [2] 3 4 5 6 7 8 9
查看完整版本: Python:每日一题 90(答题领鱼币)