a= "hello"
通过将a中的值不断的写入到b字符串中,得到b的的值类似如下:
hello,
hello,
hello,
hello
代码操作方式:
#!/usr/bin/env python # coding = UTF-8 #Author:Lucky,time:2020/8/24 a = "hello" b = "" num = 3 for i in range(num): #修改num值,可以不断向b中写入a的内容 b+=a+",\n" if i==num-1: #最后一行不需要加 逗号 b+=a
print("b的结果为如下:\n"+b)