ICode9

精准搜索请尝试: 精确搜索
  • 【Python】文件读写2022-09-03 15:31:39

    一、Python读取txt文件 text_file = "xxx.txt" with open(text_file) as f: lines = f.readlines() lines = [line.strip() for line in lines] print(lines) 二、Python写入txt文件 out_text_file = "xxx.txt" with open(out_text_file, 'w') as f

  • 一段脚本解读2022-08-31 18:30:08

    一段脚本解读 with open("../xl-20160426/Makefile") as f: lines = f.readlines() 打开文件Makefile,赋值给lines lines[0] = "Q = "+str(q)+"\n" lines[1] = "M = "+str(m-1)+"\n" lines[2] = "N = "+str(n-m-2)+&qu

  • 利用python 在txt中添加指定内容2022-07-27 17:03:31

    利用python 在txt中添加指定内容 一、原txt的内容   二、添加内容后的txt   三、代码   import os # 文件夹的路径 scr = 'E:\DATASET\Main' # 获取文件夹下的txt的文件名 fs = os.listdir(scr) print(fs) for fz in fs: # txt文件路径 src_folder = scr + "\\"

  • P1948 [USACO08JAN]Telephone Lines S2022-07-17 10:35:55

    [USACO08JAN]Telephone Lines S 题目描述 Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There are N (1 ≤ N

  • P1948 [USACO08JAN]Telephone Lines S (分层图最短路/二分+最短路)2022-07-11 16:05:13

    题目描述 [USACO08JAN]Telephone Lines S 题目描述 Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to the phone system. There are

  • NC14326 Rails2022-07-02 01:32:46

    NC14326 Rails 题目 题目描述 There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track.

  • 保留最后N个元素2022-07-01 14:01:03

    1. collections中的deque函数可以进行匹配,并返回匹配的最后N行 from collections import deque def search(lines,pattern,history=5): previous_lines = deque(maxlen=history) for line in lines: if pattern in line: yield line,previous_lines

  • 1. 文件乱码2022-06-25 22:32:53

    1 #include<vector> 2 #include <fstream> 3 #include <iostream> 4 #include<string> 5 #include <Windows.h> 6 using namespace std; 7 8 string UTF8ToGB(const char* str); 9 int main() 10 { 11 ifstream in_file; 12

  • 从git日志中统计各个人员提交代码行数2022-06-20 11:04:53

    git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --since=2022-01-01 --until=2022-05-01 --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END

  • 【动手学深度学习pytorch】学习笔记 8.2 文本预处理2022-06-09 12:01:11

    8.2. 文本预处理 — 动手学深度学习 2.0.0-beta0 documentation (d2l.ai) 1. 改写为读本地文件 2. 增加更多输出项,研究内部结构 编程环境:pycharm,python 3.9 将文本作为字符串加载到内存中。 将字符串拆分为词元(如单词和字符)。 建立一个词表,将拆分的词元映射到数字索引。 将

  • Delphi ADOConnection 捕捉错误2022-06-05 15:35:58

    procedure TForm1.con1ExecuteComplete(Connection: TADOConnection; RecordsAffected: Integer; const Error: Error; var EventStatus: TEventStatus; const Command: _Command; const Recordset: _Recordset);begin mmo1.Lines.Add('con1ExecuteComplete');

  • 数字金字塔2022-05-25 13:03:11

    数字金字塔 import java.util.*; class Main { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter the lines: "); int lines = input.nextInt(); if(lines >= 1 && lines &

  • 文件处理2022-05-24 02:31:39

    #文件读取path=r'D:\Python学习\day1\a.txt'f=open(path,encoding='utf-8')print(f)txt=f.read()print(txt)f.close()#文件写入# path=r'D:\Python学习\day1\a.txt'# f=open(path,'w')# f.write('this is test')# f.closed#统计文件里

  • String.lines()2022-04-01 19:34:22

     String.lines() lines()方法是 static 静态方法。它返回从给定多行字符串中提取的行流,并用行终止符分隔。 ? Syntax 1 2 3 4 /** * returns - the stream of lines extracted from given string */ public Stream<String> lines() 行终止符是以下之一:

  • halcon-hough_lines霍夫变换寻找直线2022-04-01 07:31:41

      在HDevelop中 read_image (Image, 'D:/bb/tu/20.jpg') get_image_size (Image, Width, Height) sobel_amp (Image, EdgeAmplitude, 'sum_abs', 3) *计算边缘 threshold (EdgeAmplitude, Region, 50, 255) *通过阈值把边缘图像变成区域 connection (Region, ConnectedRe

  • python运维常用模块(四)——文件对比模块difflib2022-03-30 17:32:53

    1.difflib介绍 difflib作为Python的标准库模块,无需安装,作用是对比文本之间的差异,且支持输出可读性较强的HTML文档,与linux下的diff命令类似。我们可以使用difflib对比代码,配置文件的差别,在版本控制方面是非常有用。Python2.3或更高版本默认自带difflib模块,无需额外安装。 实例1:两个

  • 3.Spark设计与运行原理,基本操作2022-03-10 14:04:13

    1.Spark已打造出结构一体化、功能多样化的大数据生态系统,请用图文阐述Spark生态系统的组成及各组件的功能      Spark Core: 是整个BDAS生态系统的核心组件,是一个分布式大数据处理框架。其包含Spark最基础和最核心的功能,如内存计算、任务调度、部署模式、故障恢复、存储管理等,

  • IDEA项目结构出现 0% methods,0% lines covered2022-03-01 16:32:22

    IDEA项目结构后出现 0% methods,0% lines covered, 如图 解决上述问题,只需要使用快捷键 Ctrl + Alt + F6,在弹出窗口中取消项目前面的√, 点击show selected  后续会持续更新一些IDEA中的操作。

  • 基于边缘检测和透视变换的文档图像校正2022-01-17 23:03:42

    实验任务与要求: 对发生透视变换的文档图像进行几何校正处理,得到规范的文档图像。 几何校正的目的是把发生了透视变换的目标变换为具有真实比例和角度的目标,如下图所示:左图中的地板砖经过透视变换之后,不再是正方形,经过校正之后,得到右侧图像,其中的地板砖被校正为正方形: 本次

  • Python读取txt文件查找对应内容并生成新文件2022-01-04 12:02:45

    def modifyip(tfile, deviceAddress): # tfile为目标文件,deviceAddress为要查找的条件 desktop_path = 'C:/Users/JiajunHu/Desktop/' # 新创建的txt文件的存放路径 full_path = desktop_path + deviceAddress + '.txt' # 以deviceAddress为文件名 try:

  • Rain_w and Lines2022-01-02 14:02:02

    链接:登录—专业IT笔试面试备考平台_牛客网 来源:牛客网   时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K 64bit IO Format: %lld 题目描述 Rain_w gives you two different points P(x1,y1),Q(x2,y2)P(x_1,y_1),Q(x_2,y_2)P(x1​,y1​),Q

  • 【Rust】按行读取2021-12-29 11:05:15

    环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/std_misc/file/read_lines.html 示例 main.rs use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { if let Ok(lines) = read_lines("src/m

  • 利用python遍历文件夹里每个txt文件2021-12-28 12:58:41

    利用python遍历文件夹里每个txt文件 需求:有一个文件夹,里面有很多txt文件,现在需要查看每个txt文件是否有关键词"boat",如果有,则计数加一,注意每个txt文件里面可能有多个"boat",但只计数一个。最后输出有几个txt文件里面有关键词"boat" import os def read_path(file_pathname):

  • Excel--比较两列数据的异同2021-12-24 10:33:00

    首先得到的数据分为两列,两种类型。由于在网站上搜索的时候,网站的"特殊性"会将000638-32-4 前面的0全部去掉。变成了638-32-4。基于得到了两列稍有不同的数据。由于人工看太费时间和脑力。所有首先用Python编写一个程序,将前面的0全部去掉。代码如下: data = open('40000xxlist1.txt

  • git代码量统计2021-12-22 14:34:10

    所有人 git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, r

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有