随笔分类 -  Python

上一页 1 2 3 4 5 6 ··· 11 下一页
摘要:无法连接仓库:Command "git ls-remote -h -- https://gitee.com/xxx/xxxrned status code 128: stdout: stderr: remote: [session-554c92af] Username for 'https 阅读全文
posted @ 2023-08-23 15:01 胖豆芽 阅读(1891) 评论(0) 推荐(0)
摘要:import os # 1 获取当前文件的绝对路径目录 Dir=os.path.abspath(__file__) print(f"1 绝对路径:{Dir}") # 2 去掉文件名称 保留获取目录 DirNo=os.path.dirname(Dir) print(f'2 去掉名称保留路径:{DirN 阅读全文
posted @ 2023-08-22 15:59 胖豆芽 阅读(34) 评论(0) 推荐(0)
摘要:import json class MyClass(): # 类变量 can1 = "dog" can2 = "wang" # 方法2 def is_json(self, data): try: return json.load(data) except: return data # 方法1 def 阅读全文
posted @ 2023-08-22 12:36 胖豆芽 阅读(16) 评论(0) 推荐(0)
摘要:一个参数传递时结果:(参数1) 两个参数传递时: 参数1 参数2 对(a,)暴力解决办法: 下标取值a[0] >a 阅读全文
posted @ 2023-08-22 10:44 胖豆芽 阅读(25) 评论(0) 推荐(0)
摘要:#\libs\request_test.pyfrom libs.login_my import Login from libs.food_my import Food # 调用登录获得token l=Login() t=l.login(is_need_token=True) # 将登录获得的toke 阅读全文
posted @ 2023-08-21 12:42 胖豆芽 阅读(21) 评论(0) 推荐(0)
摘要:import inspect def fun1(): fun2() def fun2(): who=inspect.stack()[1][3] # 记录被谁调用了 print(f"{who}") print(type(who)) fun1() ''' 'fun1' <class 'list'> '' 阅读全文
posted @ 2023-08-18 16:29 胖豆芽 阅读(8) 评论(0) 推荐(0)
摘要:一般的文件 读取的包含换行符 是数组格式 # open def get_yaml(file_path): with open(file_path,encoding='utf-8') as fo: print(fo.readlines()) if __name__ == '__main__': get 阅读全文
posted @ 2023-08-16 15:53 胖豆芽 阅读(28) 评论(0) 推荐(0)
摘要:# *args **kwargs的用法 def get_data(name,age,*args,**kwargs): print(f"name:{name},age:{age},可变参数:{args},可变键值对参数:{kwargs}") if __name__ == '__main__': get 阅读全文
posted @ 2023-08-16 15:30 胖豆芽 阅读(7) 评论(0) 推荐(0)
摘要:没有使用类时 # 练习基本语法 求班级中小于3岁孩子的男生是 女生是 def get_m(students, minage=3): # 男生的列表 malelist = [] # 遍历全部的学生 for student in students: # 筛选出小于3岁的孩子 if student['ag 阅读全文
posted @ 2023-08-16 14:45 胖豆芽 阅读(13) 评论(0) 推荐(0)
摘要:numbers = [4, 2, 1, 3, 5] numbers.sort() print(numbers) # 输出: [1, 2, 3, 4, 5] 阅读全文
posted @ 2023-08-14 16:51 胖豆芽 阅读(24) 评论(0) 推荐(0)
摘要:def example_func(**kwargs): for key, value in kwargs.items(): print(f"{key}: {value}") example_func(name="Alice", age=25, city="New York") 阅读全文
posted @ 2023-08-14 16:33 胖豆芽 阅读(11) 评论(0) 推荐(0)
摘要:# 导入正则表达式 import re # 参数2 str1 = "<html>a='as1d32as1d654as54d65asd465asd4'</html>" # 参数1 pattern = r"<html>a=(.*?)</html>" # 调用re中的寻找方法search result = 阅读全文
posted @ 2023-08-14 16:31 胖豆芽 阅读(12) 评论(0) 推荐(0)
摘要:with open("file.txt", "r") as file: lines = file.readlines() print(lines) # ['Line 1\n', 'Line 2\n', 'Line 3\n'] with open("file.txt", "r") as file: c 阅读全文
posted @ 2023-08-14 15:55 胖豆芽 阅读(70) 评论(0) 推荐(0)
摘要:alist1=["apple","banana","orange"] alist2=["pear","peach","watermelon"] alist1.append(alist2) print(alist1) ''' ['apple', 'banana', 'orange', ['pear', 阅读全文
posted @ 2023-08-14 15:46 胖豆芽 阅读(75) 评论(0) 推荐(0)
摘要:str1 = 'agcadssadjkl' one=str1.index('a',) t=str1.index('a',one+1) s=str1.index('a',t+1) print(one) print(t) print(s) ''' 037 ''' 阅读全文
posted @ 2023-08-14 15:30 胖豆芽 阅读(44) 评论(0) 推荐(0)
摘要:import inspect def func1(): caller = inspect.stack()[1].function ''' stack 堆栈;[0] 是自己所在的方法; [1]是被调用的方法 ''' print(f"func1方法被{caller}方法调用了") def func2() 阅读全文
posted @ 2023-08-14 14:44 胖豆芽 阅读(17) 评论(0) 推荐(0)
摘要:项目工程格式如下 1.写一个flask功能 app/app.py from flask import Flask app = Flask(__name__) @app.route("/index") def index(): return "Hello World!" if __name__ == 阅读全文
posted @ 2023-08-11 20:20 胖豆芽 阅读(187) 评论(0) 推荐(0)
摘要:1. 新建一个flask工程文件 2. 将工程文件,打包成一个txt 文件 pip freeze >req.txt 未完待续 阅读全文
posted @ 2023-08-10 17:32 胖豆芽 阅读(15) 评论(0) 推荐(0)
摘要:去掉了注册signup.html页,因为是最简单的一个工程,不验证账号的唯一性 /**创建flask数据库**/ CREATE DATABASE flask CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; /**创建用户表**/ CREATE TA 阅读全文
posted @ 2023-08-09 18:08 胖豆芽 阅读(69) 评论(0) 推荐(0)
摘要:# configs/configs.ini [servers] DEV = http://ip:port #libs/login_sig.pyimport requests import hashlib import configparser def get_host(): conf_info=co 阅读全文
posted @ 2023-08-08 22:20 胖豆芽 阅读(134) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 ··· 11 下一页