摘要: 模块:模块其实就是一个python文件1、标准模块、标准包# python自带的这些模块,直接import就能用的import string, random, datetime, os, json2、第三方模块,别人写好的一些模块,你要安装之后才可以用 1、傻瓜式的 pip install XXXX 阅读全文
posted @ 2018-04-20 00:04 彼得潘jd 阅读(116) 评论(0) 推荐(0) 编辑
摘要: import random,string# print(string.printable)#代表数字+字母+特殊字符# print(random.randint(1,10)) #随机取整数# print(round(random.uniform(1,99),2))#随机小数# print(rando 阅读全文
posted @ 2018-04-20 00:04 彼得潘jd 阅读(89) 评论(0) 推荐(0) 编辑
摘要: id()# 看内存地址type() #看数据类型print()input()list()set()str()dict()int()float()print(all([1,2,3,4]))#判断可迭代的对象里面的值是否都为真print(any([0,1,2,3,4]))#判断可迭代的对象里面的值是否有 阅读全文
posted @ 2018-04-20 00:03 彼得潘jd 阅读(108) 评论(0) 推荐(0) 编辑
摘要: def test1(): num=int(input('please enter a number:')) if num%2==0:#判断输入的数字是不是偶数 return True#如果是偶数的话,程序就退出了,返回true print('不是偶数请重新输入!') return test1()#如 阅读全文
posted @ 2018-04-20 00:02 彼得潘jd 阅读(92) 评论(0) 推荐(0) 编辑
摘要: # def syz(*args): #参数组# print(args)## syz()## syz('tywerwero','wer',23)# syz('ll')# 1、必填参数还是非必填的——非必填# 2、它有没有限制参数个数——没有# 3、它是把传过来的参数入在哪里——元组# def syz( 阅读全文
posted @ 2018-04-20 00:02 彼得潘jd 阅读(102) 评论(0) 推荐(0) 编辑
摘要: # import json# # json串是一个字符串# f=open('product.json',encoding='utf-8')# res=f.read()# print(json.loads(res))## # json串转成字典# product_dic=json.loads(res) 阅读全文
posted @ 2018-04-20 00:00 彼得潘jd 阅读(98) 评论(0) 推荐(0) 编辑
摘要: import jsondef op_data(filename,dic=None): if dic:#写入进去 with open(filename,'w',encoding='utf-8') as fw: json.dump(dic,fw,ensure_ascii=False,indent=4) 阅读全文
posted @ 2018-04-20 00:00 彼得潘jd 阅读(88) 评论(0) 推荐(0) 编辑