1樓:Dardog
import
string
import
itertools
pool
=string
.ascii_letters
+string
.digits
with
open
("result.txt"
,"w")as
fp:forcase
initertools
.product
(pool
,repeat=4
):case=""
.join(x
*3forx
incase)fp
.write(f
"\n")
2樓:HighcoolRex
Python 3.9.7 (tags/v3.
9.7:1016ef3, Aug 30 2021, 20:
19:38) [MSC v.1929 64 bit (AMD64)] on win32
>>> import string
>>> lst = str(string.digits) + string.ascii_lowercase + string.ascii_uppercase
>>> cnt = 0
>>> ft = open('combinations.txt',"a")
Traceback (most recent call last):
File "", line 1, in
PermissionError: [Errno 13] Permission denied: 'combinations.txt'
>>> for x in lst:
... for y in lst:
for z in lst:
for f in lst:
ft.write(x*3 + y*3 + z*3 + f*3)
ft.write("\n")
cnt +=1
Traceback (most recent call last):
File "", line 5, in
NameError: name 'ft' is not defined
>>> ft.close()
Traceback (most recent call last):
File "", line 1, in
NameError: name 'ft' is not defined
>>> print('一共有%d種組合' % cnt)
一共有0種組合
>>>這個是啥子情況,我現下了乙個python3.9我該怎麼辦
3樓:超級文員
import
string
lst=
str(
string
.digits)+
string
.ascii_lowercase
+string
.ascii_uppercase
cnt=0ft
=open
('combinations.txt'
,"a"
)forxin
lst:
fory
inlst
:forzin
lst:
forf
inlst:ft
.write(x
*3+y
*3+z
*3+f
*3)ft
.write("
\n")cnt+=1
ft.close
('一共有
%d種組合'
%cnt
)一共的組合數14776336,符合4個62相乘的積。
純數字的集合
import
string
lst=
str(
string
.digits
)cnt=0
ft=open
('combinations.txt'
,"a"
)forxin
lst:
fory
inlst
:forzin
lst:
forf
inlst:ft
.write(x
*3+y
*3+z
*3+f
*3)ft
.write("
\n")cnt+=1
ft.close
('一共有
%d種組合'
%cnt)
如何在真人CS中盡可能的擊中敵人,不被敵人擊中?
水飛 室內環境一般都很複雜,不考驗你動腦,就考驗反應,不過建議可以注意先佔高點,我看了一下圖,好像是上下兩層吧,肯定要先把高處佔上一點,下面的人要交替掩護,把正面拉寬,防止突出的人被人家蹦出來的人從側面給乾掉了,可以分兩路出發,找好掩護,而且是要後面往前走交替往前走的,把對面人習慣出現的地方觀察好,...
如何在增肌的過程中盡可能低的保持體脂?
神羽GK 總體來說,不管是自然還是科技選手,都會增肌增脂不可避免 這是一年前的狀態 這是昨天的狀態 按理來說,如果只是追求 低體脂 而不是完美的線條,那熱量盈餘就盡量使用高碳水,並且控制在500卡以內,脂肪攝入要特別低,在脂肪攝入少的情況下,脂肪合成的效率很低,並且高碳水能保證乙個良好的訓練狀態 高...
如何在世界征服者4中用德國贏得勝利
晚安 我試過一次不氪就可以贏的,前期在西線堆堡壘,所有將軍去打東線,打完莫斯科及主要城市,就去回頭打西線,在打的過程中,趁機偷點巴爾幹半島那片的城市,佔了之後用要塞守著不要以兵為主,最後,瘋狂造海軍擊敗西線海軍,然後鋼鐵洪流直衝美洲,最後兩路合圍。從東西兩個夾角進行攻擊,前期主要是守住西線進攻,然後...