我有一个字符串表示一个Unix时间戳(例如“1284101485”)在Python中,我想将其转换为可读日期。当我使用time.strftime
时,我会得到一个TypeError
:
>>>import time
>>>print time.strftime("%B %d %Y", "1284101485")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument must be 9-item sequence, not str
import re s = "TheQuickBrownFox" s = re.sub('([A-Z])', r'_\1', s).lower().lstrip('_') print(s)
输出结果为:the_quick_brown_fox - slushy