摘要: # 可变类型 list dict set# 不可变类型 ser tuple int float bool,必须声明 global() 才能修改names=["赵琴","赵艳萍","小苗"] #这里面是全局变量def add_name(): name=input("name:") names.appe 阅读全文
posted @ 2021-10-15 14:06 王王的王 阅读(123) 评论(0) 推荐(0)
摘要: import time#格式化好的时间#时间戳 从unix 元年到现在过了多少秒# print(time.time())#当前的时间戳# print(time.strftime('%Y-%m-%d %H:%M:%S'))#当前格式化好的时间,根据指定格式显示的#时间元组t=time.gmtime(2 阅读全文
posted @ 2021-10-15 14:05 王王的王 阅读(85) 评论(0) 推荐(0)
摘要: 1、cmd:简单快捷pip install pymysql未完待续 阅读全文
posted @ 2021-10-15 13:52 王王的王 阅读(84) 评论(0) 推荐(0)
摘要: #导入模块原理import tools #方式一 #handler引用tools 导入模块的实质就是把这个python执行了一遍tools.mysql()print(tools.size)from tools import mysql,size #方式二mysql()print(size)#查找模块 阅读全文
posted @ 2021-10-15 09:57 王王的王 阅读(231) 评论(0) 推荐(0)
摘要: #和系统相关的模块import osret=os.listdir(r"E:\Thz\day-1")#传一个路径,把路径列出来print(ret)os.path.getsize("大小")#获取文件大小os.path.join("e:","logs","a.txt") #自动拼路径 import os 阅读全文
posted @ 2021-10-15 09:56 王王的王 阅读(210) 评论(0) 推荐(0)
摘要: #自带函数,不需要定义,直接就可以日常使用sum([1,2,3]) #int类型 求和min("123") #最小 字符串max([1,2,3]) #最大round(1,9842,2) #保留n位小数 后边写几保留几位小数sorted(s)#排序,它返回一个list 默认升序sorted(s,rev 阅读全文
posted @ 2021-10-15 09:54 王王的王 阅读(321) 评论(0) 推荐(0)
摘要: #练习#回文串# s1="上海自来水来自上海"# print(s1==s1[::-1])s="A man, a plan, a canal: Panama"# 1,.循环字符串,判断字符串里面的每个字符是否为符号,如果是符号,不处理# 2.把字符串转成大写或小写#3.反转一下判断s="Amanapl 阅读全文
posted @ 2021-09-09 17:34 王王的王 阅读(401) 评论(0) 推荐(0)
摘要: #非空既真,非0即真 简化代码,TrueFalse#非空username=input("numuber:").strip() #存入东西变量里面不是空,值就是真的if username: #true 假设什么也不输username空的,就变成false print("nihao,%s",userna 阅读全文
posted @ 2021-09-09 17:33 王王的王 阅读(60) 评论(0) 推荐(0)
摘要: f=open(r"C:\Users\Administrator\Desktop\w.txt",encoding="utf-8")while True: #死循环,因为不知道循环多少次 content=f.readline() #一行一行读 print(content) if not content: 阅读全文
posted @ 2021-09-09 17:32 王王的王 阅读(58) 评论(0) 推荐(0)
摘要: 1.定义: (1)使用{}定义 s = {1, 2, 3, 4, 4} (2)空集合定义:s=set() s2=set() 2.特点: (1)集合天生就可以去重,即使定义的时候有重复 运行是也可以自动去掉(2)集合是无序的 不可以通过下标进行取值 可以循环 集合天生可以去重# s={1,1,1,2, 阅读全文
posted @ 2021-09-09 17:32 王王的王 阅读(289) 评论(0) 推荐(0)