
Python
小二_沏杯二锅头
这个作者很懒,什么都没留下…
展开
-
Python题:合并两个字符串数组的值A和B到C
如题:A = [ 'a,1', 'bb,3,22', 'c,3,4', 'b,5']B = [ 'a,2', 'bb,1', 'd,2', 'a,3']现要求合并A和B到C,输出C为:['a,1,2,3', 'bb,3,22,1', 'c,3,4', 'b,5', 'd,2']即A中'a', 'bb', '...原创 2019-11-02 21:55:21 · 1989 阅读 · 0 评论 -
mac下pip3 install ipython后出现-bash: ipython: command not found解决方案
Mac操作系统下,通过 pip3 install ipython 后,出现 -bash: ipython: command not found。输入 python3 -m IPython --version 查看是否安装ipython成功,显示版本信息则说明成功安装。再次输入python -m IPython 成功启动ipython。说明是可以启动成功,只不过启动指令稍微复杂,现在要...原创 2019-08-28 00:14:44 · 4336 阅读 · 0 评论 -
用Python只要3行代码实现快速排序?
def quick_sort(arr: list): """stable quicksort""" if len(arr) <= 1: return arr return quick_sort([i for i in arr[1:] if i <= arr[0]]) \ + [arr[0]] \ + ...原创 2019-07-14 11:44:47 · 176 阅读 · 0 评论 -
素因数分解式-求一个正整数的所有素因数的乘积
题目:如图Python实现:"""分解素因数"""import mathdef is_prime(num: int) -> bool: """判断是否是素数""" if num <= 1: return False if num <= 3: return True # 不在6的倍数两侧的一定不是...原创 2019-09-25 00:34:39 · 1530 阅读 · 0 评论