随笔分类 -  Python

摘要:给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。 你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。 你可以按任意顺序返回答案。 来源:力扣(LeetCode)链接:htt 阅读全文
posted @ 2021-07-06 10:37 沈晓桐 阅读(54) 评论(0) 推荐(0) 编辑
摘要:psutil: (Running Processes and System Utilization) psutil is a cross-platform library for retrieving information on running processes and system utili 阅读全文
posted @ 2019-05-09 14:00 沈晓桐 阅读(238) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/ JoyceLiuHome/articles/7852871.html 特别说明,本文是在Windows64位系统下进行的,32位系统请下载相应版本的安装包,安装方法类似。 使用python开发,环境有Python2和 python3 两种,有时候需要 阅读全文
posted @ 2019-01-09 16:44 沈晓桐 阅读(358) 评论(0) 推荐(0) 编辑
摘要:原文链接: http://blog.chinaunix.net/uid-25992400-id-3283846.html 任何语言都离不开字符,那就会涉及对字符的操作,尤其是脚本语言更是频繁,不管是生产环境还是面试考验都要面对字符串的操作。 python的字符串操作通过2部分的方法函数基本上就可以解 阅读全文
posted @ 2018-05-29 15:43 沈晓桐 阅读(300) 评论(0) 推荐(0) 编辑
摘要:Python中的random模块 Python中的random模块用于生成随机数。下面介绍一下random模块中最常用的几个函数。 random.random random.random()用于生成一个0到1的随机符点数: 0 <= n < 1.0 random.uniform random.uni 阅读全文
posted @ 2017-12-08 11:10 沈晓桐 阅读(238) 评论(0) 推荐(0) 编辑
摘要:http://blog.csdn.net/zklth/article/details/8117207 1 import sys 2 3 from _winreg import * 4 5 # tweak as necessary 6 version = sys.version[:3] 7 insta 阅读全文
posted @ 2017-08-25 13:45 沈晓桐 阅读(185) 评论(0) 推荐(0) 编辑
摘要:Talk is cheap,Show me the code! “‘ 第 0001 题: 做为 Apple Store App 独立开发者,你要搞限时促销,为你的应用生成激活码(或者优惠券),使用 Python 如何生成 200 个激活码(或者优惠券)? ’” 有参考和借鉴,写这篇随笔是为了记忆和理 阅读全文
posted @ 2017-08-22 11:22 沈晓桐 阅读(687) 评论(0) 推荐(0) 编辑
摘要:使用pip安装pillow: 一.在Python 目录下安装 pip C:\Python27\Scripts>easy_install.exe pip Searching for pip Best match: pip 9.0.1 Adding pip 9.0.1 to easy-install.p 阅读全文
posted @ 2017-08-17 16:07 沈晓桐 阅读(192) 评论(0) 推荐(0) 编辑
摘要:from sys import stdout ,stdin f=open(r"c:\text\somefile.txt") open(filename,mode,buffering) mode 'r' read 'w' writ 'a' 追加模式 'b' 二进制模式 '+' 读写模式 bufferi 阅读全文
posted @ 2017-08-16 13:30 沈晓桐 阅读(1102) 评论(0) 推荐(0) 编辑
摘要:猴子选大王问题: 一堆猴子都有编号,编号是1,2,3 ...m ,这群猴子(m个)按照1到m的顺序围坐一圈, 从第1开始数,每数到第n个,该猴子就要离开此圈,这样依次下来,直到圈中只剩下最后一只猴子,则该猴子为大王。 经典算法(C#版本) 1 public int King(int M, int N 阅读全文
posted @ 2017-08-14 20:54 沈晓桐 阅读(2845) 评论(0) 推荐(0) 编辑
摘要:是我写的普通不用生成器版本: l=[]for i in range(10): l.append([]) for j in range(i+1): l[i].append(0) #用0占位置,我之前没有占位置时候,初始化为l=[[],[]]会显示index out of range.不知道为何,我是初 阅读全文
posted @ 2017-08-11 18:16 沈晓桐 阅读(577) 评论(0) 推荐(0) 编辑
摘要:random 模块位于Python标准库中 因此首先导入import random部分函数功能介绍 一 random.random() 生成0<=n<1随机浮点数 二 random.unifrom(a,b) 生成指定范围内的浮点数,包含a,b 三 random.randint(a,b) 生成指定范围 阅读全文
posted @ 2017-08-09 11:24 沈晓桐 阅读(1674) 评论(0) 推荐(0) 编辑
摘要:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。 python 2 代码 #!/usr/bin/python# -*- coding: UTF-8 -*- import strings = raw_input('input a string:\n')letters = 0space 阅读全文
posted @ 2017-08-03 10:47 沈晓桐 阅读(25056) 评论(1) 推荐(1) 编辑