Skip to content

Commit 0fca52c

Browse files
committed
python中常用的内置模块
1 parent a955722 commit 0fca52c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

exercise/built_in_module_test.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# python中的常用的内置模块
2+
import sys
3+
import time
4+
# 文件输入输出
5+
# import os
6+
# import calendar
7+
# 网络请求相关
8+
import urllib.request
9+
10+
# import json
11+
# 正则表达式
12+
# import re
13+
# import math
14+
# import decimal
15+
# import logging
16+
17+
print('----------------使用sys模块---------------------')
18+
# 获取整数24在python中占用的字节大小
19+
print(sys.getsizeof(24))
20+
print(sys.getsizeof(45))
21+
print(sys.getsizeof(True))
22+
print(sys.getsizeof(False))
23+
24+
print('----------------使用sys模块---------------------')
25+
# 输出单位为秒
26+
print(time.time())
27+
print(time.localtime(time.time()))
28+
29+
print('----------------使用os模块---------------------')
30+
print(urllib.request.urlopen('http://www.baidu.com').read())
Loading

0 commit comments

Comments
 (0)