simtoolsz 0.2.14.2__tar.gz → 0.2.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/.gitignore +1 -0
  2. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/PKG-INFO +2 -1
  3. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/examples/conversion_examples.py +28 -22
  4. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/examples/special2db_example.py +48 -45
  5. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/examples/today_examples.py +32 -32
  6. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/examples/zip2db_example.py +84 -53
  7. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/pyproject.toml +2 -1
  8. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/requirements-dev.lock +3 -1
  9. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/requirements.lock +3 -1
  10. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/__init__.py +10 -3
  11. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/countrycode.py +98 -39
  12. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/datetime.py +91 -71
  13. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/db.py +77 -48
  14. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/mail.py +123 -70
  15. simtoolsz-0.2.16/src/simtoolsz/math.py +92 -0
  16. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/reader.py +127 -118
  17. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/utils.py +48 -22
  18. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_conversion.py +27 -21
  19. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_countrycode.py +50 -44
  20. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_countrycode_optimization.py +54 -33
  21. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_iso_comprehensive.py +39 -32
  22. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_iso_format.py +8 -5
  23. simtoolsz-0.2.16/tests/test_load_data_optimization.py +185 -0
  24. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_optimized_reader.py +18 -13
  25. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_simple.py +13 -10
  26. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_smoke.py +32 -8
  27. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_special2db.py +98 -78
  28. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_special2db_simple.py +57 -52
  29. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_today_optimized.py +41 -39
  30. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_which_format.py +19 -17
  31. simtoolsz-0.2.16/tests/test_zip2db.py +105 -0
  32. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/test_zip2db_simple.py +43 -37
  33. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/tests/verify_unicode_fix.py +26 -23
  34. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/uv.lock +82 -1
  35. simtoolsz-0.2.14.2/tests/test_zip2db.py +0 -101
  36. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/.github/workflows/publish.yml +0 -0
  37. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/.github/workflows/test.yml +0 -0
  38. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/.python-version +0 -0
  39. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/LICENSE +0 -0
  40. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/README.md +0 -0
  41. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/README_EN.md +0 -0
  42. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/README_countrycode.md +0 -0
  43. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/README_countrycode_en.md +0 -0
  44. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/docs/DATETIME_CONVERSION.md +0 -0
  45. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/docs/iso3166-1.xlsx +0 -0
  46. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/docs/mail_usage_guide.md +0 -0
  47. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/docs/special2db_usage.md +0 -0
  48. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/examples/mail_examples.py +0 -0
  49. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/columns_info +0 -0
  50. {simtoolsz-0.2.14.2 → simtoolsz-0.2.16}/src/simtoolsz/country.parquet +0 -0
@@ -9,3 +9,4 @@ wheels/
9
9
 
10
10
  # venv
11
11
  .venv
12
+ .trae/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: simtoolsz
3
- Version: 0.2.14.2
3
+ Version: 0.2.16
4
4
  Summary: A simple and convenient toolkit containing useful functions, classes, and methods.
5
5
  Project-URL: Homepage, https://github.com/SidneyLYZhang/simtoolsz
6
6
  Project-URL: Repository, https://github.com/SidneyLYZhang/simtoolsz.git
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
19
  Requires-Python: >=3.11
20
20
  Requires-Dist: duckdb>=1.4.0
21
+ Requires-Dist: numpy>=2.4.4
21
22
  Requires-Dist: pendulum>=3.1.0
22
23
  Requires-Dist: polars>=1.33.1
23
24
  Requires-Dist: pyarrow>=22.0.0
@@ -3,97 +3,102 @@
3
3
 
4
4
  from simtoolsz.datetime import TimeConversion, DurationFormat
5
5
 
6
+
6
7
  def main():
7
8
  """展示时间格式转换的各种用法"""
8
-
9
+
9
10
  print("=== 时间格式转换示例 ===\n")
10
-
11
+
11
12
  # 示例1: 中文时间到秒
12
13
  print("1. 中文时间到秒")
13
14
  tc = TimeConversion("1天2小时30分钟45秒", "chinese")
14
15
  seconds = tc.convert("seconds")
15
16
  print(f" 1天2小时30分钟45秒 = {seconds}秒")
16
-
17
+
17
18
  # 示例2: 秒到中文时间
18
19
  print("\n2. 秒到中文时间")
19
20
  tc = TimeConversion(90061, "seconds")
20
21
  chinese = tc.convert("chinese")
21
22
  print(f" 90061秒 = {chinese}")
22
-
23
+
23
24
  # 示例3: 英文时间到分钟
24
25
  print("\n3. 英文时间到分钟")
25
26
  tc = TimeConversion("2.5 hours 30 minutes", "english")
26
27
  minutes = tc.convert("minutes")
27
28
  print(f" 2.5 hours 30 minutes = {minutes}分钟")
28
-
29
+
29
30
  # 示例4: 冒号时间到秒
30
31
  print("\n4. 冒号时间到秒")
31
32
  tc = TimeConversion("01:30:45.5", "colon")
32
33
  seconds = tc.convert("seconds")
33
34
  print(f" 01:30:45.5 = {seconds}秒")
34
-
35
+
35
36
  # 示例5: 毫秒到小时
36
37
  print("\n5. 毫秒到小时")
37
38
  tc = TimeConversion(3600000, "milliseconds")
38
39
  hours = tc.convert("hours")
39
40
  print(f" 3600000毫秒 = {hours}小时")
40
-
41
+
41
42
  # 示例6: 多种格式间的相互转换
42
43
  print("\n6. 多种格式间的相互转换")
43
44
  original = "2小时30分钟"
44
-
45
+
45
46
  # 中文 -> 各种格式
46
47
  tc = TimeConversion(original, "chinese")
47
-
48
+
48
49
  print(f" 原始: {original}")
49
50
  print(f" 秒: {tc.convert('seconds')}")
50
51
  print(f" 分钟: {tc.convert('minutes')}")
51
52
  print(f" 小时: {tc.convert('hours')}")
52
53
  print(f" 英文: {tc.convert('english')}")
53
54
  print(f" 冒号: {tc.convert('colon')}")
54
-
55
+
55
56
  # 示例7: 使用DurationFormat枚举
56
57
  print("\n7. 使用DurationFormat枚举")
57
58
  tc = TimeConversion(3600, DurationFormat.SECONDS)
58
-
59
- for fmt in [DurationFormat.MINUTES, DurationFormat.HOURS,
60
- DurationFormat.CHINESE, DurationFormat.ENGLISH]:
59
+
60
+ for fmt in [
61
+ DurationFormat.MINUTES,
62
+ DurationFormat.HOURS,
63
+ DurationFormat.CHINESE,
64
+ DurationFormat.ENGLISH,
65
+ ]:
61
66
  result = tc.convert(fmt)
62
67
  print(f" 3600秒 -> {fmt.value}: {result}")
63
-
68
+
64
69
  # 示例8: 动态格式切换
65
70
  print("\n8. 动态格式切换")
66
71
  tc = TimeConversion(7200) # 默认是seconds
67
72
  print(f" 默认格式: {tc.get_format()}")
68
73
  print(f" 7200秒 = {tc.convert('minutes')}分钟")
69
-
74
+
70
75
  # 创建一个新的TimeConversion实例,输入是2小时
71
76
  tc2 = TimeConversion(2, "hours")
72
77
  result = tc2.convert("seconds")
73
78
  print(f" 2小时 = {result}秒")
74
-
79
+
75
80
  # 示例9: ISO 8601 格式转换
76
81
  print("\n9. ISO 8601 格式转换")
77
-
82
+
78
83
  # 秒到ISO 8601
79
84
  tc = TimeConversion(90061, "seconds")
80
85
  iso_format = tc.convert("iso8601")
81
86
  print(f" 90061秒 = {iso_format}")
82
-
87
+
83
88
  # ISO 8601到秒
84
89
  tc = TimeConversion("P1DT1H1M1S", "iso8601")
85
90
  seconds = tc.convert("seconds")
86
91
  print(f" P1DT1H1M1S = {seconds}秒")
87
-
92
+
88
93
  # 复杂ISO 8601格式
89
94
  tc = TimeConversion("PT2H30M15.5S", "iso8601")
90
95
  print(f" PT2H30M15.5S = {tc.convert('minutes')}分钟")
91
-
96
+
92
97
  # 示例10: 所有格式间的相互转换
93
98
  print("\n10. 所有格式间的相互转换")
94
99
  original = 3661.5 # 1小时1分钟1.5秒
95
100
  tc = TimeConversion(original, "seconds")
96
-
101
+
97
102
  print(f" 原始: {original}秒")
98
103
  print(f" 中文: {tc.convert('chinese')}")
99
104
  print(f" 英文: {tc.convert('english')}")
@@ -104,5 +109,6 @@ def main():
104
109
  print(f" 小时: {tc.convert('hours')}")
105
110
  print(f" 天: {tc.convert('hours') / 24}")
106
111
 
112
+
107
113
  if __name__ == "__main__":
108
- main()
114
+ main()
@@ -8,11 +8,12 @@ import tempfile
8
8
  from pathlib import Path
9
9
  from simtoolsz.db import special2db
10
10
 
11
+
11
12
  def create_sample_data():
12
13
  """创建示例数据"""
13
-
14
+
14
15
  tmpdir = Path(tempfile.mkdtemp())
15
-
16
+
16
17
  # 创建TSV文件 - 用户数据
17
18
  tsv_content = """user_id\tname\tage\tcity\temail
18
19
  1\tAlice\t25\tNew York\talice@example.com
@@ -20,42 +21,43 @@ def create_sample_data():
20
21
  3\tCharlie\t35\tTokyo\tcharlie@example.com
21
22
  4\tDiana\t28\tParis\tdiana@example.com
22
23
  5\tEve\t32\tBerlin\teve@example.com"""
23
- tsv_file = tmpdir / 'users.tsv'
24
- tsv_file.write_text(tsv_content, encoding='utf-8')
25
-
24
+ tsv_file = tmpdir / "users.tsv"
25
+ tsv_file.write_text(tsv_content, encoding="utf-8")
26
+
26
27
  print(f"示例数据已创建在: {tmpdir}")
27
28
  print(f"TSV文件: {tsv_file}")
28
-
29
+
29
30
  return tmpdir, tsv_file
30
31
 
32
+
31
33
  def main():
32
34
  """主函数"""
33
35
  print("=== special2db 函数使用示例 ===\n")
34
-
36
+
35
37
  tmpdir, tsv_file = create_sample_data()
36
-
38
+
37
39
  # 示例1: 读取单个TSV文件
38
40
  print("--- 示例1: 读取单个TSV文件 ---")
39
41
  with tempfile.TemporaryDirectory() as test_dir:
40
42
  test_dir = Path(test_dir)
41
- db_file = test_dir / 'users.db'
42
-
43
+ db_file = test_dir / "users.db"
44
+
43
45
  con = special2db(tsv_file, db_file)
44
-
46
+
45
47
  try:
46
48
  # 显示表信息
47
49
  tables = con.execute("SHOW TABLES").fetchall()
48
50
  print(f"创建的表: {[table[0] for table in tables]}")
49
-
51
+
50
52
  # 显示数据
51
- if 'users' in [t[0] for t in tables]:
53
+ if "users" in [t[0] for t in tables]:
52
54
  count = con.execute("SELECT COUNT(*) FROM users").fetchone()[0]
53
55
  print(f"记录数: {count}")
54
-
56
+
55
57
  # 显示表结构
56
58
  columns = con.execute("DESCRIBE users").fetchall()
57
59
  print(f"列信息: {[(col[0], col[1]) for col in columns]}")
58
-
60
+
59
61
  # 显示前3条数据
60
62
  data = con.execute("SELECT * FROM users LIMIT 3").fetchall()
61
63
  print(f"前3条数据:")
@@ -63,82 +65,83 @@ def main():
63
65
  print(f" {row}")
64
66
  finally:
65
67
  con.close()
66
-
68
+
67
69
  # 示例2: 使用自定义表名
68
70
  print("\n--- 示例2: 使用自定义表名 ---")
69
71
  with tempfile.TemporaryDirectory() as test_dir:
70
72
  test_dir = Path(test_dir)
71
- db_file = test_dir / 'custom_name.db'
72
-
73
- con = special2db(tsv_file, db_file, table='客户表')
74
-
73
+ db_file = test_dir / "custom_name.db"
74
+
75
+ con = special2db(tsv_file, db_file, table="客户表")
76
+
75
77
  try:
76
78
  tables = con.execute("SHOW TABLES").fetchall()
77
79
  print(f"创建的表: {[table[0] for table in tables]}")
78
-
79
- if '客户表' in [t[0] for t in tables]:
80
+
81
+ if "客户表" in [t[0] for t in tables]:
80
82
  count = con.execute("SELECT COUNT(*) FROM 客户表").fetchone()[0]
81
83
  print(f"客户表记录数: {count}")
82
-
84
+
83
85
  # 查询特定数据
84
86
  data = con.execute("SELECT * FROM 客户表 WHERE age > 30").fetchall()
85
87
  print(f"年龄大于30的客户: {data}")
86
88
  finally:
87
89
  con.close()
88
-
90
+
89
91
  # 示例3: 处理目录
90
92
  print("\n--- 示例3: 处理目录 ---")
91
93
  with tempfile.TemporaryDirectory() as test_dir:
92
94
  test_dir = Path(test_dir)
93
-
95
+
94
96
  # 创建多个TSV文件
95
- users_tsv = test_dir / 'users.tsv'
96
- users_tsv.write_text(tsv_file.read_text(), encoding='utf-8')
97
-
98
- products_tsv = test_dir / 'products.tsv'
97
+ users_tsv = test_dir / "users.tsv"
98
+ users_tsv.write_text(tsv_file.read_text(), encoding="utf-8")
99
+
100
+ products_tsv = test_dir / "products.tsv"
99
101
  products_content = """product_id\tname\tprice\tcategory\tstock
100
102
  101\t笔记本电脑\t8999\t电子产品\t50
101
103
  102\t无线鼠标\t199\t配件\t200
102
104
  103\tUSB硬盘\t599\t存储\t80
103
105
  104\t显示器\t1599\t电子产品\t30
104
106
  105\t键盘\t299\t配件\t150"""
105
- products_tsv.write_text(products_content, encoding='utf-8')
106
-
107
- db_file = test_dir / 'directory.db'
107
+ products_tsv.write_text(products_content, encoding="utf-8")
108
+
109
+ db_file = test_dir / "directory.db"
108
110
  con = special2db(test_dir, db_file)
109
-
111
+
110
112
  try:
111
113
  tables = con.execute("SHOW TABLES").fetchall()
112
114
  print(f"创建的表: {[table[0] for table in tables]}")
113
-
115
+
114
116
  # 查询每个表
115
- for table_name in ['users', 'products']:
117
+ for table_name in ["users", "products"]:
116
118
  if table_name in [t[0] for t in tables]:
117
- count = con.execute(f"SELECT COUNT(*) FROM {table_name}").fetchone()[0]
119
+ count = con.execute(
120
+ f"SELECT COUNT(*) FROM {table_name}"
121
+ ).fetchone()[0]
118
122
  print(f"{table_name}表记录数: {count}")
119
123
  finally:
120
124
  con.close()
121
-
125
+
122
126
  # 示例4: 使用额外的DuckDB参数
123
127
  print("\n--- 示例4: 使用额外的DuckDB参数 ---")
124
128
  with tempfile.TemporaryDirectory() as test_dir:
125
129
  test_dir = Path(test_dir)
126
- db_file = test_dir / 'with_params.db'
127
-
130
+ db_file = test_dir / "with_params.db"
131
+
128
132
  # 为TSV文件指定编码和其他参数
129
- con = special2db(tsv_file, db_file,
130
- encoding='utf-8',
131
- header=True)
132
-
133
+ con = special2db(tsv_file, db_file, encoding="utf-8", header=True)
134
+
133
135
  if con:
134
136
  try:
135
137
  tables = con.execute("SHOW TABLES").fetchall()
136
138
  print(f"创建的表: {[table[0] for table in tables]}")
137
139
  finally:
138
140
  con.close()
139
-
141
+
140
142
  print("\n=== 所有示例完成 ===")
141
143
  print("special2db 函数使用示例结束")
142
144
 
145
+
143
146
  if __name__ == "__main__":
144
- main()
147
+ main()
@@ -13,75 +13,75 @@ from simtoolsz.utils import today
13
13
 
14
14
  def main():
15
15
  print("=== today() 函数使用示例 ===\n")
16
-
16
+
17
17
  # 1. 基本用法 - 获取当前日期(返回 DateTime 对象)
18
18
  print("1. 获取当前日期对象:")
19
19
  current_date = today()
20
20
  print(f" today() = {current_date}")
21
21
  print(f" 类型: {type(current_date)}")
22
22
  print()
23
-
23
+
24
24
  # 2. 获取标准 datetime 对象
25
25
  print("2. 获取标准 datetime 对象:")
26
26
  std_datetime = today(return_std=True)
27
27
  print(f" today(return_std=True) = {std_datetime}")
28
28
  print(f" 类型: {type(std_datetime)}")
29
29
  print()
30
-
30
+
31
31
  # 3. 获取当前日期时间
32
32
  print("3. 获取当前日期时间对象:")
33
33
  current_datetime = today(addtime=True)
34
34
  print(f" today(addtime=True) = {current_datetime}")
35
35
  print(f" 类型: {type(current_datetime)}")
36
36
  print()
37
-
37
+
38
38
  # 4. 格式化日期输出
39
39
  print("4. 格式化日期输出:")
40
- formatted_date = today(fmt='YYYY-MM-DD')
40
+ formatted_date = today(fmt="YYYY-MM-DD")
41
41
  print(f" today(fmt='YYYY-MM-DD') = '{formatted_date}'")
42
42
  print(f" 类型: {type(formatted_date)}")
43
43
  print()
44
-
44
+
45
45
  # 5. 格式化日期时间输出
46
46
  print("5. 格式化日期时间输出:")
47
- formatted_datetime = today(addtime=True, fmt='YYYY-MM-DD HH:mm:ss')
47
+ formatted_datetime = today(addtime=True, fmt="YYYY-MM-DD HH:mm:ss")
48
48
  print(f" today(addtime=True, fmt='YYYY-MM-DD HH:mm:ss') = '{formatted_datetime}'")
49
49
  print()
50
-
50
+
51
51
  # 6. 不同时区的日期
52
52
  print("6. 不同时区的日期:")
53
- local_date = today(fmt='YYYY-MM-DD HH:mm:ss')
54
- utc_date = today(tz='UTC', fmt='YYYY-MM-DD HH:mm:ss')
55
- shanghai_date = today(tz='Asia/Shanghai', fmt='YYYY-MM-DD HH:mm:ss')
56
-
53
+ local_date = today(fmt="YYYY-MM-DD HH:mm:ss")
54
+ utc_date = today(tz="UTC", fmt="YYYY-MM-DD HH:mm:ss")
55
+ shanghai_date = today(tz="Asia/Shanghai", fmt="YYYY-MM-DD HH:mm:ss")
56
+
57
57
  print(f" 本地时区: {local_date}")
58
58
  print(f" UTC时区: {utc_date}")
59
59
  print(f" 上海时区: {shanghai_date}")
60
60
  print()
61
-
61
+
62
62
  # 7. 中文格式
63
63
  print("7. 中文格式:")
64
- chinese_date = today(fmt='YYYY年MM月DD日')
65
- chinese_datetime = today(addtime=True, fmt='YYYY年MM月DD日 HH时mm分ss秒')
64
+ chinese_date = today(fmt="YYYY年MM月DD日")
65
+ chinese_datetime = today(addtime=True, fmt="YYYY年MM月DD日 HH时mm分ss秒")
66
66
  print(f" 中文日期: {chinese_date}")
67
67
  print(f" 中文日期时间: {chinese_datetime}")
68
68
  print()
69
-
69
+
70
70
  # 8. 其他常用格式
71
71
  print("8. 其他常用格式:")
72
72
  formats = [
73
- 'DD/MM/YYYY',
74
- 'MM-DD-YYYY',
75
- 'YYYY/MM/DD HH:mm',
76
- 'dddd, MMMM D, YYYY', # 星期几,月份 日,年
77
- 'MMM D, YYYY', # 简写月份
73
+ "DD/MM/YYYY",
74
+ "MM-DD-YYYY",
75
+ "YYYY/MM/DD HH:mm",
76
+ "dddd, MMMM D, YYYY", # 星期几,月份 日,年
77
+ "MMM D, YYYY", # 简写月份
78
78
  ]
79
-
79
+
80
80
  for fmt in formats:
81
81
  result = today(addtime=True, fmt=fmt)
82
82
  print(f" {fmt:20} = {result}")
83
83
  print()
84
-
84
+
85
85
  # 9. 与 pendulum 对象的交互
86
86
  print("9. 与 pendulum 对象的交互:")
87
87
  dt_obj = today() # 获取 DateTime 对象
@@ -92,7 +92,7 @@ def main():
92
92
  print(f" 星期: {dt_obj.day_of_week}")
93
93
  print(f" 是否闰年: {dt_obj.is_leap_year()}")
94
94
  print()
95
-
95
+
96
96
  # 10. 标准 datetime 对象的使用
97
97
  print("10. 标准 datetime 对象的使用:")
98
98
  std_dt = today(addtime=True, return_std=True)
@@ -100,27 +100,27 @@ def main():
100
100
  print(f" 时间戳: {std_dt.timestamp()}")
101
101
  print(f" ISO格式: {std_dt.isoformat()}")
102
102
  print()
103
-
103
+
104
104
  # 11. 时区转换
105
105
  print("11. 时区转换示例:")
106
- utc_time = today(tz='UTC', addtime=True)
106
+ utc_time = today(tz="UTC", addtime=True)
107
107
  print(f" UTC时间: {utc_time}")
108
108
  # 转换到纽约时区
109
- ny_time = utc_time.in_timezone('America/New_York')
109
+ ny_time = utc_time.in_timezone("America/New_York")
110
110
  print(f" 纽约时间: {ny_time}")
111
111
  print()
112
-
112
+
113
113
  # 12. 组合用法示例
114
114
  print("12. 组合用法示例:")
115
115
  # 获取UTC时间的标准datetime对象
116
- utc_std = today(tz='UTC', addtime=True, return_std=True)
116
+ utc_std = today(tz="UTC", addtime=True, return_std=True)
117
117
  print(f" UTC标准datetime: {utc_std}")
118
-
118
+
119
119
  # 获取格式化的中文日期时间
120
- chinese_fmt = today(addtime=True, tz='Asia/Shanghai', fmt='YYYY年MM月DD日 HH:mm:ss')
120
+ chinese_fmt = today(addtime=True, tz="Asia/Shanghai", fmt="YYYY年MM月DD日 HH:mm:ss")
121
121
  print(f" 北京时间中文格式: {chinese_fmt}")
122
122
  print()
123
123
 
124
124
 
125
125
  if __name__ == "__main__":
126
- main()
126
+ main()