* pythonの「objectをeval()で再び元のオブジェクトに戻せる文字列に変換して返す。」というrepr(object)関数
:CATEGORIES: python
Pythonのstr( )とrepr( )の使い分け | ガンマソフト株式会社 https://gammasoft.jp/blog/use-diffence-str-and-repr-python/
In [7]: repr(users)
Out[7]: "{'a1', 'motoken_tw', 'uwaaa', 'fukazawas', 'z1', 'lawks', 'lawks2', 'b1'}"In [8]: print(users)
{'a1', 'motoken_tw', 'uwaaa', 'fukazawas', 'z1', 'lawks', 'lawks2', 'b1'}In [9]: import datetime
In [10]: today = datetime.date.today()
In [11]: print(today)
2020-09-17In [12]: repr(today)
Out[12]: 'datetime.date(2020, 9, 17)'In [13]: today.type
- -
AttributeError Traceback (most recent call last)
in
- > 1 today.type
AttributeError: 'datetime.date' object has no attribute 'type'
In [14]: type(tody)
- -
NameError Traceback (most recent call last)
in
- > 1 type(tody)
NameError: name 'tody' is not defined
In [15]: today.type
- -
AttributeError Traceback (most recent call last)
in
- > 1 today.type
AttributeError: 'datetime.date' object has no attribute 'type'
In [16]: type(today)
Out[16]: datetime.date
In [17]: day = datetime.date(2020, 9, 17)
In [18]: day
Out[18]: datetime.date(2020, 9, 17)
In [19]: print(day)
2020-09-17
In [20]: type(day)
Out[20]: datetime.date