Python打印出当前时间
时间: 2023-06-21 07:16:08 浏览: 50
好的,以下是Python打印当前时间的代码:
```python
import datetime
now = datetime.datetime.now()
print("当前时间是:")
print(now.strftime("%Y-%m-%d %H:%M:%S"))
```
运行代码后,即可在控制台上看到当前时间。
相关问题
python打印出当前时间
好的,以下是Python打印当前时间的代码:
```python
import datetime
now = datetime.datetime.now()
print("当前时间是:")
print(now.strftime("%Y-%m-%d %H:%M:%S"))
```
运行代码后,即可在控制台上看到当前时间。
python 打印当前时间
你可以使用 Python 的 datetime 模块来打印当前时间。以下是一个示例代码:
```python
import datetime
current_time = datetime.datetime.now()
print("当前时间:", current_time)
```
这段代码会打印出当前的日期和时间。你可以根据需要格式化输出的时间,例如使用 strftime() 函数来指定特定的格式。