- SSH:安全外壳协议 SSH: Secure Shell Protocol 安全外壳协议(SSH)是一种在不安全网络上提供安全远程登录及其它安全网络服务的协议。 说明:以下代码使用windows访问linux(centos) 安装第三方库 pip install paramiko 1 1. SSHClient方式 1.1 基于用户名和密码 imp... SSH:安全外壳协议 SSH: Secure Shell Protocol 安全外壳协议(SSH)是一种在不安全网络上提供安全远程登录及其它安全网络服务的协议。 说明:以下代码使用windows访问linux(centos) 安装第三方库 pip install paramiko 1 1. SSHClient方式 1.1 基于用户名和密码 imp...
- 问题来了 使用 reduce() 测试的时候报错:reduce 未定义! print(reduce(lambda x, y: x + y, [ 1, 2, 3])) """Output: NameError: name 'reduce' is not defined """12345 解决 引用stackoverflow的回答: - 你使用的是pyth... 问题来了 使用 reduce() 测试的时候报错:reduce 未定义! print(reduce(lambda x, y: x + y, [ 1, 2, 3])) """Output: NameError: name 'reduce' is not defined """12345 解决 引用stackoverflow的回答: - 你使用的是pyth...
- # -*-coding:utf-8-*- html = """ <html> <head> <base href='http://example.com/' /> <title>Example website</title> </head> <body> <di... # -*-coding:utf-8-*- html = """ <html> <head> <base href='http://example.com/' /> <title>Example website</title> </head> <body> <di...
- 文件结构 ./ |--main.py |--clazz |--demo.txt 12345 获取clazz包下面的demo.txt文件 main.py import pkgutil ret = pkgutil.get_data("clazz", "demo.txt") print(ret) 12345 此方法替换__file__ 文件结构 ./ |--main.py |--clazz |--demo.txt 12345 获取clazz包下面的demo.txt文件 main.py import pkgutil ret = pkgutil.get_data("clazz", "demo.txt") print(ret) 12345 此方法替换__file__
- 一层装饰器 # -*- coding: utf-8 -*- def func1(func): print("func1-1") def inner1(): print("inner1-1") func() print("inner1-2") print("func1-2") return inner1 @func1 def func(): print("fun... 一层装饰器 # -*- coding: utf-8 -*- def func1(func): print("func1-1") def inner1(): print("inner1-1") func() print("inner1-2") print("func1-2") return inner1 @func1 def func(): print("fun...
- from timeit import timeit from timeit import repeat # 执行1000000次x=1的时间 t1 = timeit("x=1") print("t1", t1) # x=1的执行时间,执行1次(number可以省略,默认值为1000000) t2 = timeit('x=1', number=1) print("t2... from timeit import timeit from timeit import repeat # 执行1000000次x=1的时间 t1 = timeit("x=1") print("t1", t1) # x=1的执行时间,执行1次(number可以省略,默认值为1000000) t2 = timeit('x=1', number=1) print("t2...
- 装饰器: 定义:本质是函数,装饰其他函数,为其他函数添加附加功能 原则: 1、不能修改被装饰的函数源代码 2、不能修改被装饰的函数的调用方式 原理: 1.函数即“变量” 2.高阶函数 a.把函数名当做实参传递给函数b.返回一个函数名 3.嵌套函数 总结: 高阶函数 + 嵌套函数 =》 装饰器 import time def timer(arg): # 可以接... 装饰器: 定义:本质是函数,装饰其他函数,为其他函数添加附加功能 原则: 1、不能修改被装饰的函数源代码 2、不能修改被装饰的函数的调用方式 原理: 1.函数即“变量” 2.高阶函数 a.把函数名当做实参传递给函数b.返回一个函数名 3.嵌套函数 总结: 高阶函数 + 嵌套函数 =》 装饰器 import time def timer(arg): # 可以接...
- python实现脚本命令行的库有: 内置库sys内置库argparse第三方库click第三方库fire 内置库sys sys.argv 包含命令行参数列表,第一个参数是文件名 sys_demo.py import sys def add(a, b): return a + b if __name__ == '__main__': ret = add(s... python实现脚本命令行的库有: 内置库sys内置库argparse第三方库click第三方库fire 内置库sys sys.argv 包含命令行参数列表,第一个参数是文件名 sys_demo.py import sys def add(a, b): return a + b if __name__ == '__main__': ret = add(s...
- 文档:http://docs.peewee-orm.com/ 安装 $ pip install peewee 1 将已有数据表转为Model # 导出数据表为Model $ python -m pwiz -e mysql -H localhost -p 3306 -u root -P -o -i -t user data > user.py 12 打印执... 文档:http://docs.peewee-orm.com/ 安装 $ pip install peewee 1 将已有数据表转为Model # 导出数据表为Model $ python -m pwiz -e mysql -H localhost -p 3306 -u root -P -o -i -t user data > user.py 12 打印执...
- python 递归调用默认上限:1000次 1、比较运算符: __cmp__(self,other)比较 __eq__(self,other)相等 __lt__(self,other)小于 __gt__(self,other)大于 2、逻辑运算符: __... python 递归调用默认上限:1000次 1、比较运算符: __cmp__(self,other)比较 __eq__(self,other)相等 __lt__(self,other)小于 __gt__(self,other)大于 2、逻辑运算符: __...
- money模块对货币进行简单的包装,实现简单的货币计算 安装 pip install money 1 代码示例 from money import Money m1 = Money("2.0", "RMB") print(m1) # RMB 2.00 print(m1.amount) # 2.0 print(m1.currency) # RMB m2 =... money模块对货币进行简单的包装,实现简单的货币计算 安装 pip install money 1 代码示例 from money import Money m1 = Money("2.0", "RMB") print(m1) # RMB 2.00 print(m1.amount) # 2.0 print(m1.currency) # RMB m2 =...
- 参照我原来的文章打包上传pypi包时报错: Python编程:为世界贡献你的轮子-pipy打包 error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>1 看到网上说此方法已经不支持 需要用 twine 模块打包 ... 参照我原来的文章打包上传pypi包时报错: Python编程:为世界贡献你的轮子-pipy打包 error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)>1 看到网上说此方法已经不支持 需要用 twine 模块打包 ...
- itertools库包含: 无限迭代器有限序列处理排列组合 range对象 # 添加函数说明 def print_info(obj: "iter object") -> "print_info": print(obj) print(type(obj)) print(list(obj)) # help(print_info) # print_info(... itertools库包含: 无限迭代器有限序列处理排列组合 range对象 # 添加函数说明 def print_info(obj: "iter object") -> "print_info": print(obj) print(type(obj)) print(list(obj)) # help(print_info) # print_info(...
- 模块介绍: Reads the key,value pair from .env file and adds them to environment variable. Do one thing, do it well! pypi: https://pypi.org/project/python-dotenv/ github: https://github.com/t... 模块介绍: Reads the key,value pair from .env file and adds them to environment variable. Do one thing, do it well! pypi: https://pypi.org/project/python-dotenv/ github: https://github.com/t...
- # -*- coding:utf-8 -*- class Clazz: name = "" def getName(self): pass def getAge(self): pass def get_methods(self): return (list(filter(lambda m: not m.startswith("_") and callable(g... # -*- coding:utf-8 -*- class Clazz: name = "" def getName(self): pass def getAge(self): pass def get_methods(self): return (list(filter(lambda m: not m.startswith("_") and callable(g...
上滑加载中
推荐直播
-
华为云码道 × 仓颉编程:工程化AI编码探索2026/05/27 周三 19:00-21:00
刘俊杰-华为云仓颉语言专家/李炎-华为云码道技术专家/王智鹏-OpenCangjie开源社区发起人
本场直播围绕华为云仓颉语言与华为云码道的深度结合,展示华为云智能编程从零基础到高效落地的完整生态能力。以华为云码道为引擎,仓颉语言为载体,带给大家日常提效、趣味创新到极速量产的开发体验。
回顾中
热门标签