2018年1月7日 星期日

Permutations 列舉





# permutations 列舉法
import itertools
print (list(itertools.permutations([1,2,3,4], 2)))
print (list(itertools.permutations(['j','o','h','n'], 2)))
print (list(itertools.permutations(['j','o','n'], 3)))


=========== RESTART: F:/Python_APSC/b038-2.py ==============
[(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)]
[('j', 'o'), ('j', 'h'), ('j', 'n'), ('o', 'j'), ('o', 'h'), ('o', 'n'), ('h', 'j'), ('h', 'o'), ('h', 'n'), ('n', 'j'), ('n', 'o'), ('n', 'h')]
[('j', 'o', 'n'), ('j', 'n', 'o'), ('o', 'j', 'n'), ('o', 'n', 'j'), ('n', 'j', 'o'), ('n', 'o', 'j')]
>>> 

沒有留言:

張貼留言

Node-Red --> MQTT --> Fuxa 開源碼網頁式圖控平台

Node-Red --> MQTT --> Fuxa      FUXA(一個開源的 Web HMI / SCADA 自動化監控軟體)的專案設定檔 。 這份設定檔完整定義了 HMI 監控畫面的 後端通訊(MQTT 連線、點位標籤) 與 前端網頁圖形介面(SVG 畫布...