摘要: 一、定义一个类 class 类名(): 类的属性 对象属性 类的方法 对象方法 class Person(object): name = 'tom' //类属性 def hello(self): //对象方法 print(Person.name) //类调用类属性 print(self.name) 阅读全文
posted @ 2020-12-02 19:03 lnterpreter 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 一、读取文件 with open('pass.txt','r') as f: content = f.read() //一次读取所有内容 print(content) with open('pass.txt','r') as f: //将所有内容读取到一个列表中 for line in f.read 阅读全文
posted @ 2020-12-02 17:05 lnterpreter 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 获取路径 import os //导入模块 print(os.getcwd()) //打印当前路径 os.chdir("C:\\Windows\\System32") //修改当前路径 print(os.getcwd()) 增删目录文件 os.makedirs("E:\\a\\b") //创建目录, 阅读全文
posted @ 2020-12-02 15:50 lnterpreter 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 一、定义一个函数 def hello(name): print('hello ' + name) name = input('请输入您的用户名: ') hello(name) 二、多参数 def hello(name1,name2): print('hello ' + name1 + ' ' +na 阅读全文
posted @ 2020-12-02 15:10 lnterpreter 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 循环遍历字典 user = {'admin1':'123456','admin2':'test123','admin3':'admin888'} //定义一个字典 for item in user.items(): if item[0] == 'admin' and item[1] == 'admi 阅读全文
posted @ 2020-12-02 14:55 lnterpreter 阅读(80) 评论(0) 推荐(0) 编辑