wsndc 发表于 2022-3-3 18:09:55

输出50个*

输出*号的方法
我知道的只有while循环和for循环,要输出50个*号
例如:
while x<=50:
        print('*',end='')
        x+=1
还有啥方法?

True_123 发表于 2022-3-3 18:31:45

是什么输出格式呢?

python爱好者. 发表于 2022-3-3 18:34:25

直接这样:
print("*" * 50)

wsndc 发表于 2022-3-3 18:39:06

True_123 发表于 2022-3-3 18:31
是什么输出格式呢?

格式随便吧,反正输出50个*就行了

wsndc 发表于 2022-3-3 18:40:32

python爱好者. 发表于 2022-3-3 18:34
直接这样:

还有吗?越多越好{:10_254:}

太阳总会升起 发表于 2022-3-3 18:42:25

三楼的是最简单的了吧

python爱好者. 发表于 2022-3-3 18:45:08

wsndc 发表于 2022-3-3 18:40
还有吗?越多越好

没了,循环大法是最好用的{:10_304:}

人造人 发表于 2022-3-3 19:39:06

#!/usr/bin/env python
#coding=utf-8

print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')
print('*', end = '')

人造人 发表于 2022-3-3 19:41:25

生成程序的程序

#!/usr/bin/env python
#coding=utf-8

print('#!/usr/bin/env python')
print('#coding=utf-8')
print('')

count = 50
while count:
    print("print('*', end = '')")
    count -= 1

人造人 发表于 2022-3-3 20:06:36

#!/usr/bin/env python
#coding=utf-8

print('**************************************************')

傻眼貓咪 发表于 2022-3-4 10:17:07

这是基本知识吧?
print ('*' * 50)

elven08 发表于 2022-3-4 10:48:44

def u(a):
    b = "*" * a
    return(b)

a = int(input("请输入重复次数:"))
print(u(a))

elven08 发表于 2022-3-4 10:51:33

还可以继续玩
def u(a,b):
    c = a * b
    return(c)

a = input("请输入重复符号:")
b = int(input("请输入重复次数:"))
print(u(a,b))

elven08 发表于 2022-3-4 10:56:57

简单点
a,b=(input("请输入重复符号:"),int(input("请输入重复次数:")))
print(a * b)

mist1208 发表于 2022-3-5 18:40:22

print("*\n" * 50)

True_123 发表于 2022-3-6 10:49:28

for a in range(1,50):
    print('*')

还有:
a=[]
for num in range(1,50):
    a.append('*')

还有:
..........

print(a)
页: [1]
查看完整版本: 输出50个*