目前我正在学习 python 脚本并试图获得以下输出1BCD2BCD3BCD11CD21CD31CD12CD22CD32CD13CD23CD33CD111D211D311D121D221D321D等等......直到最后一个字符如何实现?我正在使用 python 3.0,请在下面找到我的代码:import sysdef tv(): GET = 'ABCD' INC = 0 IGKINNER = 0 COUNT = 0 i = 0 while (COUNT < 1): IGKINNER = IGKINNER + 1 try: for h in range(len(GET)): print('GET', GET) INC = INC + 1 if (INC == 1): GET = GET.replace(GET[IGKINNER], chr(49), 1) if (INC == 2): GET = GET.replace(GET[IGKINNER], chr(50), 1) if (INC == 3): GET = GET.replace(GET[IGKINNER], chr(51), 1) if (INC >=4): INC = 0 break except: COUNT = 3 returntv()请帮助我,非常感谢
2 回答
斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
您对所需内容的描述不是很清楚,但这会产生您想要的样子(GET每次都无需打印):
def tv():
base = "ABCD"
nums = "123"
s4 = base[3]+nums
s3 = base[2]+nums
s2 = base[1]+nums
for c4 in s4:
for c3 in s3:
for c2 in s2:
for c1 in nums:
print(c1+c2+c3+c4)
s2 = nums
s3 = nums
添加回答
举报
0/150
提交
取消