繁体   English   中英

Python itertools:如何将排列打印为垂直列表

[英]Python itertools: how to print permutations as a vertical list

我正在尝试将 output 作为垂直列表,但不知道在可迭代位置使用哪个值? 我只需要按所有可能的顺序查看 6 个值。

请参阅下面的代码。 谢谢您的帮助。

import itertools
print(list(itertools.permutations(['1 Download the App and create an app account', '2 Choose the station on the map or by searching on the station name in the search field', '3 choose connector', '4 Choose payment method, and process the payment of the pre-authorization fee', '5 Connect the cable to vehicle to start charging', '6 Review the price tariff and click on Start Charging'], 6)))
print(*iterable, sep = '\n')

例如像这样:

myList = ['1 Download the App and create an app account', '2 Choose the station on the map or by searching on the station name in the search field', '3 choose connector', '4 Choose payment method, and process the payment of the pre-authorization fee', '5 Connect the cable to vehicle to start charging', '6 Review the price tariff and click on Start Charging']

for p in itertools.permutations(myList, 6):
    print(*p, sep='\n')
    print()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM