上一页 1 2 3 4 5 6 ··· 12 下一页
摘要: [TOC] # 1. 使用sprintf, printf ## 1.1: 10进制 -> 非10进制 ```perl my $num = 10; my $s_hex_low = sprintf "%04x", $num; # 000a, 10进制->16进制小写 my $s_hex_high= sp 阅读全文
posted @ 2023-07-15 17:59 编程驴子 阅读(137) 评论(0) 推荐(0) 编辑
摘要: [TOC] # 1. Getopt::Long ```perl #使用模块 use Getopt::Long ; #选项初始值 my $length = 24 ; my $file = "file.dat"; my @run = (); my $verbose =0; #处理选项 # 如果参数解析成 阅读全文
posted @ 2023-07-15 17:27 编程驴子 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 命令行运行perl语句 [TOC] # 1. -n -e选项 ```csh cat file.txt | perl -ne '$a += s/pattern//g; END {print "$a\n"}' ``` 作用:计算文件file.txt中匹配“pattern”的个数。 说明: ``` 1. 阅读全文
posted @ 2023-07-15 17:04 编程驴子 阅读(128) 评论(0) 推荐(0) 编辑
摘要: # 1. 条件语句: ```perl if (boolean_expr0) { #expr0 为true时执行 } elsif (boolean_expr1) { #expr1 为true时执行 } else { #没条件匹配时执行 } unless (boolean_expr0) { #expr0 阅读全文
posted @ 2023-07-15 16:52 编程驴子 阅读(7) 评论(0) 推荐(0) 编辑
摘要: # 1. 概述 Perl是弱类型语言, 变量不需要指定类型, 解释器根据上下文自动选择匹配类型. Perl有三个基本的数据类型: 标量($), 数组(@), 哈希(%). # 2. 标量, scalar 标量变量以$标记. ```perl my $a = 123; #数字 my $b = "123" 阅读全文
posted @ 2023-07-15 16:34 编程驴子 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 面向对象语法 [TOC] # 1. 说明 perl面向对象没有什么特别的语法, 以例子介绍如下. 例子中涉及三个文件: main.pl, AllPerson.pm, Person.pm. 其中: main.pl是主脚本, 它要用到AllPerson.pm. AllPerson.pm是一个class, 阅读全文
posted @ 2023-07-15 12:12 编程驴子 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 操作剪切板数据, 需要使用模块pyperclip, 这个模块需要自己安装: pip install pyperclip 下面是使用方法 ```python import pyperclip ########################## #操作1, 读取剪切板 ################ 阅读全文
posted @ 2023-07-11 10:52 编程驴子 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 运行效果: ![](https://img2023.cnblogs.com/blog/2009209/202306/2009209-20230621152313612-1184296600.png) 代码如下: ``` import collections import copy import ra 阅读全文
posted @ 2023-06-21 15:23 编程驴子 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 如果脚本涉及多个文件, 且分布在多个目录中, 则会涉及到import其它目录的文件. 如果脚本不在脚本所在的目录run, 则会涉及到run目录与脚本目录不相关. 如何解决这个问题呢? 假设目录结构如下: ```csh /a/b/c/bin/dfx.py /a/b/c/atpg/atpg.py /a/ 阅读全文
posted @ 2023-06-12 10:31 编程驴子 阅读(21) 评论(0) 推荐(0) 编辑
摘要: ```python list_for_help = list() list_for_help.append("PyQt5.QtCore") list_for_help.append("PyQt5.QtCore.QTime") list_for_help.append("PyQt5.QtGui") l 阅读全文
posted @ 2023-06-12 10:03 编程驴子 阅读(15) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 12 下一页