直角三角形rows=int(input('输入列数:'))foriinrange(1,rows):print('*'*i)foriinrange(1,rows):forjinrange(i):print("*",end="")print("")等腰直角三角形rows=int(input('输入列数:'))foriinrange(1,rows):print('*'*i)foriinrange(1,rows):forjinrange(1,i+1):print(
系统 2019-09-27 17:54:09 2082
本文实例为大家分享了python3.6tkinter实现屏保小程序,供大家参考,具体内容如下该小程序是在闲着没事的时候,随便写的,就当打发无聊了。该程序是用python3.6写的,调用了python中的tkinter的库(*python2x与python3x的thinter有很多不同的地方,一定要特别注意!!!)fromrandomimportrandintfromtkinterimport*classRandball():def__init__(self
系统 2019-09-27 17:54:02 2082
利用python库random,string生成大小写字母和数字的随机验证码importrandomimportstringdefgenerate_code(bit_num):''':parambit_num:生成验证码位数:return:返回生成的验证码'''all_str=string.printable.split('!')[0]code=''.join([random.choice(all_str)foriinrange(bit_num)])ret
系统 2019-09-27 17:54:02 2082
range([start],[end],[long])描述:根据range里的参数生成指定范围指定步长的一个序列参数:[start]——指定范围的左边界,可取到[end]——指定范围的右边界,不可取到[long]——步长,若无步长,默认为1返回值:列表实例:>>>range(0,6,2)[0,2,4]>>>range(5)[0,1,2,3,4]xrange()描述:用法与range完全相同,生成的不是数组,而是一个生成器实例:>>>xrange(0,6,2
系统 2019-09-27 17:54:01 2082
经常地我们需要编写跨平台的脚本,但是由于不同的平台的差异性,我们不得不获得当前所工作的平台(操作系统类型)。代码如下:复制代码代码如下:importplatformdefTestPlatform():print("----------OperationSystem--------------------------")#Windowswillbe:(32bit,WindowsPE)#Linuxwillbe:(32bit,ELF)print(platform
系统 2019-09-27 17:54:01 2082
#!/usr/bin/python#-*-coding:UTF-8-*-#######################################createdbybasededato####2018-01-02####监控#####################################importosimportjsonclassMonitor(object):def__init__(self,Cmd):self.Cmd=Cmd#vmsta
系统 2019-09-27 17:53:33 2082
一.问题描述Givenanintegerarraynums,findthecontiguoussubarray(containingatleastonenumber)whichhasthelargestsumandreturnitssum.Example:Input:[-2,1,-3,4,-1,2,1,-5,4],Output:6Explanation:[4,-1,2,1]hasthelargestsum=6.Followup:Ifyouhavefigur
系统 2019-09-27 17:53:31 2082
本文实例讲述了Python进程间通信Queue消息队列用法。分享给大家供大家参考,具体如下:进程间通信-QueueProcess之间有时需要通信,操作系统提供了很多机制来实现进程间的通信。1.Queue的使用可以使用multiprocessing模块的Queue实现多进程之间的数据传递,Queue本身是一个消息列队程序,首先用一个小实例来演示下Queue的工作原理:代码如下:#coding=utf-8frommultiprocessingimportQue
系统 2019-09-27 17:52:28 2082
Python语言与Perl,C和Java等语言有许多相似之处,也有一定的差异性,以下是Python语言获取文件后缀名和文件名的方法:#Python获取文件后缀名的方法importos.pathdeffile_extension(path):returnos.path.splitext(path)[1]printfile_extension('/py/a.py')输出:.py#Python获取目录和文件名importos.pathdeffile_extens
系统 2019-09-27 17:52:22 2082
在写程序时,我们经常需要定义一些路径常量,为了逻辑和代码的清晰,可以新建一个config.ini文件,然后调用其中的信息即可。config.ini文件格式如下:[section1]model_dir=/home/user/nlp-data/trained-model;注释save_input=./profiling/inputsave_state=./profiling/state......[section2]save_output=./profilin
系统 2019-09-27 17:51:24 2082