看板 [ Python ]
討論串[問題] python 變數根據變數產生問題
共 3 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 1→)留言1則,0人參與, 最新作者shaform (Shaform)時間8年前 (2017/07/02 12:27), 編輯資訊
0
0
0
內容預覽:
剛剛試了一下好像可以這樣耶 @@!!!. for i in range(100):. globals()['a{}'.format(i)] = i. print(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10). --. 發信站: 批踢踢實業坊(ptt.c

推噓0(0推 0噓 2→)留言2則,0人參與, 最新作者LessonWang (橘白Cat)時間8年前 (2017/06/25 15:39), 8年前編輯資訊
0
0
0
內容預覽:
for i in range(3):. exec("a"+str(i)+"="+str(i)). 我把eval換成exec好像可以用了xd. -----. Sent from JPTT on my Asus ASUS_Z00UD.. --. 發信站: 批踢踢實業坊(ptt.cc), 來自: 27

推噓4(4推 0噓 13→)留言17則,0人參與, 最新作者lavishfeel (..)時間8年前 (2017/06/25 15:05), 編輯資訊
0
0
0
內容預覽:
大家好. 小弟最近在學習怎麼寫python. 我想要根據變數產生更多變數. 在shell script裡面如下. i=0. while [ $i < 3 ]. do. a$i=$i. i=i+1. done. 執行後我可以得到3個變數. a0=0. a1=1. a2=2. 不知道是不是可以請問pyt
首頁
上一頁
1
下一頁
尾頁