
python
天马行空_xaut
这个作者很懒,什么都没留下…
展开
-
python四舍五入float
项目上遇到一个问题是要对folat保留2位小数,查了相关资料,python竟然没有靠谱的四舍五入的函数,自己写了一个,只是采用了C语言的方式做四舍五入,但是函数里边还需要加入一些判断条件保证健壮性,需要朋友们可以拿去直接用: def get_float_by_round(f_num, n): f_str = str(int(f_num * (10**n) + 0.5)) integral_str = f_str[:-n] fractional_str = f_str[-n:]...原创 2020-06-16 16:59:45 · 397 阅读 · 0 评论 -
python xlrd读取excel后如何去掉u
xls_keyword = xlrd.open_workbook(".xxxx.xls") table = xls_keyword.sheet_by_index(0) list_keywords = [] for tmp_keyword in table.col_values(2): tmp_keyword = tmp_keyword.strip().encode('raw_unicode_escape') list_keywords.append(tmp...原创 2020-06-16 14:05:04 · 1059 阅读 · 0 评论 -
NumPy对数组进行操作
https://www.runoob.com/numpy/numpy-array-manipulation.html原创 2020-06-12 15:30:23 · 180 阅读 · 0 评论