而不是像这样制作字母表列表:
alpha = ['a', 'b', 'c', 'd'.........'z']
Run Code Online (Sandbox Code Playgroud)
有什么方法可以将它分组到一个范围或什么的?例如,对于数字,可以使用它进行分组range()
range(1, 10)
Run Code Online (Sandbox Code Playgroud) 1.打印一个: abcdefghijklmn
2.每一秒钟: acegikm
3.附加到URL的索引{ hello.com/,hej.com/,...,hallo.com/}:hello.com/a hej.com/b ... hallo.com/n
有没有办法超越字符?这样的事情.
for c in xrange( 'a', 'z' ):
print c
Run Code Online (Sandbox Code Playgroud)
我希望你们能帮忙.
我想A, b, c, d...使用 range()打印Python中包含的英文字母,但出现 TypeError。有没有一种方法可以做到这一点而不必手动定义英文字母列表?
>>> for letter in range('a', 'z'):
... print(letters)
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object cannot be interpreted as an integer
>>>
Run Code Online (Sandbox Code Playgroud)