1. 输出算法的运行时长
import time
start_time = time.time()
// 算法处理
end_time = time.time()
print("运行时长:",(end_time-start_time),"s")
import datetime
start = datetime.datetime.now()
end = datetime.datetime.now()
print(end-start)
2. python切割字符串
txt = "Google#Taobao#Facebook"
x = txt.split("#")
print(x)
// ['Google', 'Taobao', 'Facebook']
x = txt.split("#",1)
print(x)
// ['Google', 'Taobao#Facebook']
3. 获取某字符串中括号内的内容
import re
want_str = re.findall(r'[\[](.*?)[\]]', whole_str)
4. 获取某字符串小括号内的内容
import re
want_str = re.findall(r'[(](.*?)[)]', whole_str)
5. 无穷大的表示
num1 = float("inf")
num2 = float('-Inf')