1、首先在PyCharm软件中,打开一个Python项目。

2、在Python项目中,新建并打开一个空白的python文件(比如:test.py)。

3、输入:“import time”,导入 time 模块。

4、插入语句:“now = int(time.time())”,获得当前时间时间戳。

5、插入语句:“timeArray = time.localtime(now)”,点击Enter键。

6、插入语句:“otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)”,点击Enter键。

7、插入语句:“print(otherStyleTime)”,点击Enter键。

8、在编辑区域点击鼠标右键,在弹出菜单中选择“运行”选项。

9、程序运行完毕后,可以看到已经成功地将时间戳转换为指定格式日期。
