简体   繁体   English

Python计数0-9然后是az

[英]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(仅小写),然后移动到下一个,导致:

&#xf000, &#xf001, &#xf002 ... &#xf009
&#xf00a, &#xf00b, &#xf00c ... &#xf00z
&#xf010, &#xf011, &#xf012 ... &#xf019, &#xf01a, &#xf01b, &#xf01c ... &#xf01z
&#xf0a0, &#xf0b1, &#xf0 ... &#xf019, &#xf01a, &#xf01b, &#xf01c ... &#xf01z

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 '&#xf' + ''.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.

相关问题 具有 0-9 和 AZ 的 Python 序列号生成器 - Python sequential number generator with 0-9 and A-Z 如何在 Python 中创建带有英文字母(AZ、az、0-9)的图像? - How to create images with English alphabets (A-Z, a-z, 0-9) in Python? python正则表达式re.search(r“([[az] + [AZ] + [0-9] +)”,密码) - python regular expression re.search(r“([a-z]+[A-Z]+[0-9]+)”, password) 如何在Python中仅用“ AZ”,“ az”,“ 0-9”和“ _”编码UTF-8字符串 - How to encode UTF-8 strings with only “A-Z”,“a-z”,“0-9”, and “_” in Python 如何从“0-9 AZ”按顺序“自动生成”字符串 - How to “Auto Generate” String in Sequence from “0-9 A-Z” 如何使用 re.sub() 只留下字母 az、AZ、数字 0-9 和空格而不是除数? - How to use re.sub() to leave only letters a-z, A-Z, numbers 0-9 and spaces but not divide numbers? 我如何编写regEx来识别字符串何时除了az 0-9以外的其他内容? - How do I write regEx to recognize when a string has anything but a-z 0-9? 生成两个字符的域名 az 0-9 时使用运算符出现问题 - Trouble using operator while generating two character domain names a-z 0-9 已清理的消息,仅包含字母 az 和数字 0-9,只有一个空格 - cleaned message, which contains only letters a-z, and numbers 0-9 with only one space 我怎样才能在 BeautifulSoup 中只有来自“#0-9 和 AZ”的 select 个链接? - How can I only select links from "#0-9 and A-Z" in BeautifulSoup?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM