Python中文
首页
教程
问答
标签
搜索
登录
注册
在python中生成字符串列表
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我对python很陌生,所以我想试试这个快速脚本。。。在</p> <p>给定一组输入词:例如“dead”、“beef”,如何以编程方式生成给定长度和填充字符的所有可能字符串?在</p> <p>结果如下所示(使用<code>0</code>的焊盘,长度为12):</p> <pre><code>deadbeef0000 dead0beef000 dead00beef00 dead000beef0 dead0000beef 0deadbeef000 0dead0beef00 0dead00beef0 0dead000beef 00deadbeef00 00dead0beef0 00dead00beef 000deadbeef0 000dead0beef 0000deadbeef </code></pre> <p>生成此列表的简单方法可能是:</p> ^{pr2}$ <p>有没有更直接的方法?我已经研究过<code>itertools</code>的组合,但无法使其产生所需的结果。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<pre><code>for x in range(0, 5): pre = '0' * x for y in range(0, 5-x): mid = '0' * y z = 5 - x - y post = '0' * z val = pre + 'dead' + mid + 'beef' + post print val </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
如何在python中从数据帧列中删除分类值?
5 回答
如何在python中从数据帧列表中删除引号
2 回答
如何在python中从数据帧创建列表
5 回答
如何在Python中从数据帧创建嵌套的JSON
6 回答
如何在Python中从数据帧显示wordcloud
4 回答
如何在Python中从数据帧的时间戳中删除字符
8 回答
如何在Python中从数据帧绘制简单绘图?
10 回答
如何在python中从数据帧行提取具有特定长度的范围?
7 回答
如何在python中从数据帧设置dict中的值
8 回答
如何在Python中从数据库中获得一个结果
3 回答
如何在python中从数据框中绘制分类条形图
5 回答
如何在Python中从数据框中选择特定细节?
10 回答
如何在python中从数据集中删除unicode
10 回答
如何在python中从数据集中删除某些数值?
6 回答
如何在python中从数据集中选择行
3 回答
如何在Python中从数组中删除元素
9 回答
如何在python中从数组中删除单个倒逗号?
3 回答
如何在python中从数组中删除对象?
2 回答
如何在python中从数组中删除引号
3 回答
如何在python中从数组中删除所有最小值
1 回答