一、内置函数下面简单介绍几个:1.abs()求绝对值2.all()如果iterable的所有元素都为真(或者如果可迭代为空),则返回True3.any()如果iterable的任何元素为真,则返回True。如果iterable为空,则返回False4.callable()如果object参数出现可调,则返回True,否则返回False5.divmod()以两个(非复数)数字作为参数,并在使用整数除法时返回由商和余数组成的一对数字。对于混合操作数类型,二进制
系统 2019-09-27 17:54:34 2151
Python数据科学入门DmitryZinoviev著熊子源译第二章数据科学的Python核心第4单元理解基本的字符串函数大小写转换函数:lower()将所有字符转换为小写upper()将所有字符转换为大写capitalize()将第一个字符转换为大写,同时将后面的字符都转化为小写(这些操作都不会影响其他非字母字符)字符串判定函数:islower()判断字符串中的所有字母是否都是小写isupper()判断字符串中的所有字母是否都是大写isspace()检查
系统 2019-09-27 17:53:59 2151
listlist是一种有序的集合,可以随时添加和删除其中的元素。跟java不一样的是可以使用arr[-1]0>-x>=-len(arr)索引的数字为0~len(arr)-1-len(arr)~-1超过会报错classmates=['A','B','C','D','E']print(classmates)print(len(classmates))foriinclassmates:print(i)'''['A','B','C','D','E']5ABCDE'
系统 2019-09-27 17:53:41 2151
场景CSDN:https://blog.csdn.net/badao_liumang_qizhi博客园:https://www.cnblogs.com/badaoliumangqizhi/哔哩哔哩视频教程:https://space.bilibili.com/164396311实现关注公众号:霸道的程序猿回复:Python语言书籍免费下载。
系统 2019-09-27 17:53:06 2151
英文文档classmethod(function)Returnaclassmethodforfunction.Aclassmethodreceivestheclassasimplicitfirstargument,justlikeaninstancemethodreceivestheinstance.Todeclareaclassmethod,usethisidiom:classC:@classmethoddeff(cls,arg1,arg2,...):.
系统 2019-09-27 17:52:28 2151
#coding=utf-8importxlwtimportxlrdtry:filename=xlwt.Workbook()sheet=filename.add_sheet("test")//newtabletestsheet.write(3,2,hello)//row3col2,writeword'hello'filename.save("D:/test1.xls")//saveastest1.xlsexceptException,e:print(str(
系统 2019-09-27 17:52:17 2151
程序很简单,主要是mp3play模块的应用importmp3play,timefilename="ShouldItMatter.mp3"clip=mp3play.load(filename)while1:iftime.localtime().tm_min%30==0:clip.play()print"\nStarttoplay"time.sleep(clip.seconds())clip.stop()print"Stop"print'>',time.sle
系统 2019-09-27 17:51:13 2151
基本原理蒙特卡罗方法通过抓住事物运动的几何数量和几何特征,利用数字方法来加以模拟,即进行一种数字模拟实验。它是以一个概率模型为基础,按照这个模型所描绘的过程,通过模拟实验的结果,作为问题的近似解。主要步骤如下:1.构造或描述概率过程2.实现从已知概率分布抽样3.建立各种估计量示例一:π值的计算importnumpyasnpimportpandasaspdimportmatplotlib.pyplotasplt%matplotlibinline#π的计算n=
系统 2019-09-27 17:50:56 2151
函数:startswith()作用:判断字符串是否以指定字符或子字符串开头一、函数说明语法:string.startswith(str,beg=0,end=len(string))或string[beg:end].startswith(str)参数说明:string:被检测的字符串str:指定的字符或者子字符串。(可以使用元组,会逐一匹配)beg:设置字符串检测的起始位置(可选)end:设置字符串检测的结束位置(可选)如果存在参数beg和end,则在指定范
系统 2019-09-27 17:50:52 2151
cache为实例化django中的方法get_redis_connection,感兴趣的可以尝试。importpickleimportcachekey_id=''result=cache.get(key_id)ifresult:result=pickle.loads(result)ifnotresult:result={''''''}cache.set(key_id,pickle.dumps(result))
系统 2019-09-27 17:50:33 2151