How to declare many variables?

前端 未结 5 901
醉话见心
醉话见心 2020-12-11 13:22

Here is the letters:

letters=\'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\'

I made a list of it with this:

<         


        
5条回答
  •  囚心锁ツ
    2020-12-11 13:34

    You can use either a list of tuples or a dict. A simple solution to do it:

    >>> import string
    >>> letters = string.ascii_uppercase + string.ascii_lowercase + string.digits
    >>> chars = dict.fromkeys(letters , 0)
    >>> chars
    >>> {...'a': 0, 'b': 0 ....}
    

    To use list of tuples:

    >>> list(chars.items())
    >>> [...('a',0), ('b', 0)...]
    

提交回复
热议问题