格式化持续时间 Args: seconds: 秒数 Returns: 格式化的持续时间字符串
(seconds: int)
| 442 | |
| 443 | |
| 444 | def format_duration(seconds: int) -> str: |
| 445 | """ |
| 446 | 格式化持续时间 |
| 447 | |
| 448 | Args: |
| 449 | seconds: 秒数 |
| 450 | |
| 451 | Returns: |
| 452 | 格式化的持续时间字符串 |
| 453 | """ |
| 454 | if seconds < 60: |
| 455 | return f"{seconds}秒" |
| 456 | |
| 457 | minutes, seconds = divmod(seconds, 60) |
| 458 | if minutes < 60: |
| 459 | return f"{minutes}分{seconds}秒" |
| 460 | |
| 461 | hours, minutes = divmod(minutes, 60) |
| 462 | if hours < 24: |
| 463 | return f"{hours}小时{minutes}分" |
| 464 | |
| 465 | days, hours = divmod(hours, 24) |
| 466 | return f"{days}天{hours}小时" |
| 467 | |
| 468 | |
| 469 | def mask_sensitive_data(data: Union[str, Dict, List], mask_char: str = "*") -> Union[str, Dict, List]: |
nothing calls this directly
no outgoing calls
no test coverage detected