[英]Python count 0-9 then a-z
I'm attempting to build a style sheet with this structure: 我正在尝试使用这种结构构建样式表:
.something-[content_name]:before {
content: '[unicode_string]';
}
For the style sheet, the Unicode string follows the pattern: 对于样式表,Unicode字符串遵循以下模式:
/f[0-9a-z][0-9a-z][0-9a-z]
And a set of SVGs with this structure: 和一组具有这种结构的SVG:
<glyph unicode="[unicode_string]" d="some_path" />
I have a list of things that I'm going to be inserting as content, and I need a way to iterate through and assign unicode values to the content. 我有一个列表,我将作为内容插入,我需要一种方法来迭代并为内容分配unicode值。
I want to iterate through 0-9 then az (lowercase only) in each place before moving to the next, resulting in: 我想在每个地方迭代0-9然后az(仅小写),然后移动到下一个,导致:
, ,  ... 
, ,  ... ༀz
, ,  ... , , ,  ... ༁z
, , ð ... , , ,  ... ༁z
Substituting /
for &#x
isn't an issue, I just want to know the best way to iterate through this way. 代
/
为&#x
是不是一个问题,我只是想知道通过这样的方式来循环的最佳方式。
Are you looking for itertools.product? 你在寻找itertools.product吗?
import string, itertools
for p in itertools.product(string.digits + string.ascii_lowercase, repeat=3):
print '' + ''.join(p)
For hex numbers, simply iterate over 0123456789abcdef
: 对于十六进制数,只需迭代
0123456789abcdef
:
for p in itertools.product('0123456789abcdef', repeat=3):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.