搜索结果

  • 查看Window端口占用情况

    1 命令netstat -ano | findstr 端口号

  • 获取指定目录下的所有图片信息

    1 获取指定目录下的所有图片信息// 获取指定目录下的所有图片信息 public function getImagesInfo($directory) { $images = []; // 创建递归目录迭代器 $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY ); // 遍历目录中的每个文件 foreach (

  • 关键字

    下表中是 Python 中的关键字(保留字),我们在自定义标识符时不能使用关键字。

  • 缩进

    Python 不使用 {} 来控制类、函数、逻辑判断等,而是使用缩进,缩进的空格可变。如下所示:if True: print(True)else: print(False)

  • 输入输出

    Python 输出使用 print(),内容加在括号中即可。如下所示:print('Hello Python')Python 提供了一个 input(),可以让用户输入字符串,并存放到一个变量里。如下所示:name = input()print('Hi',name)

  • 数据类型

    整数:可以为任意大小、包含负数浮点数:就是小数字符串:以单引号 '、双引号"、三引号 ''' 或 """括起来的文本布尔:只有 True、False 两种值空值:用 None 表示变量:是可变的常量:不可变

  • 注释

    Python 中单行注释使用 #,多行注释使用三个单引号(''')或三个双引号(""")。如下所示:# 我是单行注释'''我是多行注释我是多行注释'''"""我是多行注释我是多行注释"""

  • python怎么获取时间

    在Python中获取时间可以使用内置的 datetime 模块。具体来说,你可以按照以下步骤来获取当前时间:import datetime# 获取当前日期和时间current_datetime = datetime.datetime.now()# 获取当前日期current_date = datetime.date.today()# 获取当前时间current_time = datetime.datetime.now().time()# 打印结果print("当前日期和时间:", current_datetime)print("当前日期:", current_date)print("当前时间:

  • 字符串列表相互转换

    1 range()函数作用range(5)生成的序列是从0开始小于5的整数:>>> list(range(5))[0, 1, 2, 3, 4]2 字符串转列表str1 = "hi hello world"print(str1.split(" "))输出:['hi', 'hello', 'world']3 列表转字符串l = ["hi","hello","world"]print(" ".join(l))输出:hi hello world

  • 部署上线

    1 生成项目依赖文件# 项目根目录下,运行命令 pip freeze > ./requirements.txt2 根据项目依赖文件安装第三方库pip install -r requirements.txt

  • Python2和Python3的区别

    (1) 在 Python2 中,print 是一条语句,而 Python3 中作为函数存在。print 'Hello world' // 这是Python2的语法print ('Hello world') // 这是Python3的语法(2) Python2没有布尔型,数字 0 表示 False,1 表示 True。(3) Python3种True 和 False 是关键字,它们的值还是 1 和 0,可以和数字相加。(4) Python2 中有整型int 和长整型 Long(5) Python3中只有一种整数类型 int,表示为长整型,没有 Long。

  • Thinkphp各版本的PHP要求

    ThinkPHP 8.0:运行环境要求PHP8.0+,兼容PHP8.3ThinkPHP 6.1:运行环境要求PHP7.2+,兼容PHP8.1ThinkPHP 6.0:运行环境要求PHP7.2+,兼容PHP8.1ThinkPHP 5.1:运行环境要求PHP5.6+,兼容PHP8.0ThinkPHP 5.0:运行环境要求PHP5.4+,兼容PHP7.3

  • Thinkphp5.1路径常量

    1 配置文件位置根目录/config/template.php2 配置文件内容<?php// +----------------------------------------------------------------------// | ThinkPHP [ WE CAN DO IT JUST THINK ]// +----------------------------------------------------------------------// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reser

  • Thinkphp5.0路径常量

    1 配置文件位置根目录/application/模块名/config.php2 配置文件内容<?php//配置文件return [ // 后台视图输出字符串内容替换 'view_replace_str' => [ '__PUBLIC__' => '/', '__STATIC__' => '/static', '__CONSOLE__' => '/static/console', '__CONSOLE_CSS__' => '/static/console/css', '__CONSOLE_IMAGES__' => '/static/console/ima

  • 获取网络图片的宽度和高度

    // 获取网络图片的宽度和高度if (!function_exists('widht_gt_height')) { function widht_gt_height($webImage) { // 获取图片信息 $imageInfo = @getimagesize($webImage); // 检查是否成功获取图片信息 if ($imageInfo === false) { return true; } // 提取图片宽度和高度 $width = 0; if (isset($imageInfo[0]) && !empty($imageInfo[0])) { $width = $

  • 将网络图片保存到指定的目录下

    /** * 将网络图片保存到指定的目录下 * param $url 网络图片地址,例如:http://example.com/image.jpg * param $savePath 保存的图片路径,例如:/path/to/save/image.jpg*/if(!function_exists('save_image_from_url')) { function save_image_from_url($url, $savePath) { // 获取远程图片内容 $imageContent = file_get_contents($url); if ($imageContent === fals

  • 生成一个随机的图片名

    /** * 生成一个随机的图片名 * param $type 文件名的后缀 */if(!function_exists('get_image_file_name')) { function get_image_file_name($type = 'png') { if (in_array($type, ['png', 'jpg', 'jpeg'])) { return time().rand(1,99999).'.'.$type; } return ''; }}

  • 把字符串中第一个出现的子字符串替换成指定的内容

    /** * 把字符串中第一个出现的子字符串替换成指定的内容 * @param string $string 字符串 * @param string $substring 子字符串 * @param string $replacement 要替换的内容 */if(!function_exists('replace_first_sub_string')) { function replace_first_sub_string($string, $substring, $replacement) { $position = strpos($string, $substring); if ($posi