代码改变世界

函数调用

2018-04-16 14:26 by 何小六soso, 164 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-import timedef logger(): time_format = ("%Y-%m-%d %X") time_current = time.strftime(time_format) with open("logger.txt", "a+",e 阅读全文

python文件操作

2018-04-16 09:24 by 何小六soso, 324 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-#打开一个文件并读取内容#data=open("yesterday",encoding="utf-8").read()#打开一个文件并t添加文件句柄,并且标定打开文件模式,变量f# w为写模式,创建新文件,原文件被替换,w只可写不可读 w+可写可读# r 阅读全文

集合-列表的关系测试

2018-04-11 11:44 by 何小六soso, 613 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-#集合是无序的import oslist_1=[1,4,7,3,6,7,"a"]list_3=set([1,3,7])list_4=[377,88]#集合去重list_1=set(list_1)list_2=[1,33,4,7,66,5,8]#交集,取出两个列表中相同的数据list_x=list_1.intersection(list_2)#并集,合... 阅读全文

字典

2018-04-10 17:32 by 何小六soso, 112 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-#字典没有下标,打印是无序的info={ "s01":"张三", "s02":"李四", "s03":"王五", "s04":"赵六"}#如果有就修改,如果么有就增加info["s01"]="武藤兰"info["s05"]="小泽玛利亚"#删除#del 阅读全文

购买商品

2018-04-10 16:46 by 何小六soso, 291 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-#1、启动程序后让用户输入工资,并打印商品列表#2、允许用户通过商品编号购买商品#3、选择商品后判断工资是否够,够扣款,不够重新选择#4、可随时退出,退出时打印已购买商品和余额salary=int(input("请输入工资:"))#创建商品列表commo 阅读全文

列表

2018-04-10 16:04 by 何小六soso, 249 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-#增加列表names=["张三","李四","王五","赵六","赵六",[1,2,3]]#追加到最后一位names.append("和珅")#插入列表自选位置names.insert(2,"插入到王五前面")#切片,如果取后两位names[2:],不需 阅读全文

简单登录接口

2018-04-10 09:47 by 何小六soso, 176 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-#1、用户名密码#2、认证成功后显示欢迎信息#3、输错三次密码后被锁定username="hekaiqiao"password="123"count=0name=input("name:")#创建黑名单f=open("black_name","r+",e 阅读全文

While循环猜年龄

2018-04-09 16:31 by 何小六soso, 246 阅读, 0 推荐, 收藏, 编辑
摘要:# -*- coding: utf-8 -*-# 1、ly_age年龄30岁# 2、猜对退出# 3、猜错5次询问:n退出,任意键继续ly_age=30count=0while True: while count<5: age=int(input("请输入年龄:")) if ly_age==age: 阅读全文