VWED_server/docs/sc/系统线程相关.md

84 lines
1.2 KiB
Markdown
Raw Normal View History

2025-09-25 10:52:52 +08:00
```markdown
## 多线程及时间
#### 休眠指定时间
* 方法说明
2025-09-29 09:35:08 +08:00
本方法是异步方法,使当前协程休眠指定时间,不会阻塞整个系统。
2025-09-25 10:52:52 +08:00
```python
2025-09-29 09:35:08 +08:00
async def sleep(ms: int) -> None
2025-09-25 10:52:52 +08:00
```
* 输入参数
* msint 类型,休眠的时间,单位毫秒。
* 输出参数
本方法输出参数为空。
* 异常
本方法不抛出异常。
2025-09-29 09:35:08 +08:00
* 使用示例
```python
# 异步休眠1秒
await VWED.system_thread.sleep(1000)
```
2025-09-25 10:52:52 +08:00
#### 获取当前系统时间戳
* 方法说明
获取当前的系统时间戳。
```python
def current_time_millis() -> int
```
* 输入参数
* 输出参数
int 类型,当前系统的毫秒时间戳。
#### 获取当前时间
* 方法说明
获取当前系统的格式化时间。
```python
def now_date() -> str
```
* 输入参数
* 输出参数
字符串:按照 `yyyy-MM-dd HH:mm:ss` 格式。
* 异常
本方法不抛出异常。
#### 将时间戳转为日期格式
* 方法说明
将时间戳转为格式化的日期时间。
```python
def time_millis_format(time: int) -> str
```
* 输入参数
* timeint 类型,当前毫秒时间戳。
* 输出参数
字符串:按照 `yyyy-MM-dd HH:mm:ss` 格式。
* 异常
本方法会抛出异常。
```