line

23. Bash Shell - 文本处理:cat、tac、nl、head、tail

时间秒杀一切 提交于 2020-01-22 10:58:52
开篇词 结合词处理命令,我们可以简便地从文本输出或文本文档中获取我们想要的文本。 准备 我们可以借助 echo 命令来将文本输出至一个文件。 准备内容: echo "First line" >> file.txt echo "Second line" >> file.txt echo "Third line" >> file.txt echo "Fourth line" >> file.txt echo "Fifth line" >> file.txt echo "Sixth line" >> file.txt echo "Seventh line" >> file.txt echo "Eighth line" >> file.txt echo "Ninth line" >> file.txt echo "Tenth line" >> file.txt echo "Eleventh line" >> file.txt echo "Twelfth line" >> file.txt echo "Thirteenth line" >> file.txt echo "Fourteenth line" >> file.txt echo "Fifteenth line" >> file.txt echo "Sixteenth line" >> file.txt echo

3D Line - Plane intersection?

守給你的承諾、 提交于 2020-01-22 03:00:45
问题 I am having two Vectors (X,Y,Z), one above Y=0 and one below Y=0 . I want to find the Vector (X,Y,Z) where the line between the two original vectors intersects with the Y=0 level. How do I do that? Example Point A: X = -43.54235 Y = 95.2679138 Z = -98.2120361 Example Point B: X = -43.54235 Y = 97.23531 Z = -96.24464 These points read from two UnProjections from a users click and I'm trying to target the unprojection to Y=0 . (I found 3D line plane intersection, with simple plane but didn't

Java - Detect Straight Lines with given Coordinates

心不动则不痛 提交于 2020-01-21 11:48:07
问题 ADDED INFO: I'm using the inside of a square as an arena. On start up, the square spawns in a random position, and rotation, and I can't access any of the squares attributes. I then have a moving object inside the square, that I'm building AI for, and I want the object to 'learn' where the arena walls are. Every time the object bumps into a wall, I get a touch return, so I know if its hit or not. I'm using this to map the global position of where the object hit the wall and save it ... After

Drawing a line with a gradient color

隐身守侯 提交于 2020-01-21 07:08:05
问题 Is it possible to draw a line using a graduated colour? I want to be able to draw a straight or a curved line (if possible) where at one end of the line is Blue and the other end is Red. Further There might be a need to have more than one gradient per-line e.g the colour going from Blue -> Green -> Red. I am thinking that this might just consist of multiple gradient lines drawn together. 回答1: protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphicsObject = e

Python_矩阵转置

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-19 22:27:56
矩阵转置:行变列,列变行 算法:列元素放到新列表的行 list01 = [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 9 , 10 , 11 , 12 ] ] # 转置 list02 = [ ] for c in range ( len ( list01 [ 0 ] ) ) : line = [ ] for r in range ( len ( list01 ) ) : line . append ( list01 [ r ] [ c ] ) list02 . append ( line ) # 打印成表格 for line in list02 : for item in line : print ( item , end = "\t" ) print ( ) 运行结果 1 5 9 2 6 10 3 7 11 4 8 12 来源: CSDN 作者: Rookie_Max 链接: https://blog.csdn.net/Rookie_Max/article/details/104044832

MATLAB 错误使用 Error using exampleUtils.componentExamplesDir (line x)

◇◆丶佛笑我妖孽 提交于 2020-01-19 08:05:46
Error using exampleUtils.componentExamplesDir (line x) 问题描述 在使用Matlab的时候,官网上有一些例子,可以直接在Matlab命令行打开。比如使用 ‘’’ openExample(‘globaloptim/MinimizeaSimpleFunctionwithBoundsExample’) ‘’’ 打开官网上的例子的时候,出现以下错误: ‘’’ Error using exampleUtils.componentExamplesDir (line 13) Invalid argument “globaloptim”. Error in findExample (line 18) componentExamplesDir = exampleUtils.componentExamplesDir(component); Error in openExample (line 24)metadata = findExample(id); ‘’’ 分析: 出现以下错误的原因就是在打开例子之前没有安装相应的Toolbox。 解答 安装以下Global Optimization Toolbox,这个错误自然消失。 添加方式: 主页–>附加功能–>获取附加功能,然后在获取附加资源管理器中搜索Global Optimization

报错Expected 7 fields in line 9, saw 9

时间秒杀一切 提交于 2020-01-19 03:37:47
import pandas as pd data = pd.read_csv('h4.txt',encoding='gb18030',header=None,sep=None,engine='python') print(data) 报错: 解决方法: 加参数即列名:names=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17'] 加几列最终就会显示几列, 错误减少直到没有。 import pandas as pd data = pd.read_csv('h4.txt',encoding='gb18030',header=None,sep=None,engine='python',names=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17']) print(data) 成功,做下笔记。 read_csv() 接受以下常见参数: 1.filepath_or_buffer:读取文件的路径。 2.sep : 指定分隔符。如果不指定参数,则会尝试使用逗号分隔。 3.delimiter :定界符,备选分隔符(如果指定该参数,则sep参数失效) 4.engine : {‘c',

1430:家庭作业

北城以北 提交于 2020-01-18 03:01:33
1430:家庭作业 题解 本题和智力大冲浪可以说有异曲同工之喵啊,唯一不同的是本题要加上一步优化,防止超时 因为是保证学分尽量多,所以先按学分从大到小排序,把作业在规定期限内尽量靠后排 接下来讲一讲优化(借鉴了一下度娘找到的大佬的博客) 比如说我有三个作业 [ 2 6 ] [ 2 5 ] [ 2 4 ] 我把第一个作业安排到2 ,第二个作业安排到 1,那么第三个作业就不用考虑了,因为没有办法继续布置了,也就是1~line[ ].t 都已经排满了,那么我们标记一个dislike,表示从1~dislike都不可以安排作业了 如果不加优化,每个都需要for循环判断,很浪费时间 代码 #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<string> #include<queue> #include<functional> using namespace std; int n,dislike; long long ans; bool vis[1000001],fa[1000001]; struct node { int t,w; }line[1000001]; bool cmp(node x,node y) { return x.w >y.w ;

Python:如何得到Popen的输出?

左心房为你撑大大i 提交于 2020-01-18 00:34:09
最近在用subprocess中的Popen做个磁盘监控小程序,但是在使用ps = Popen("df -h", shell=True, stdout=PIPE, stderr=PIPE)之后,再使用output_lines = ps.stdout.readlines()的时候,output_lines总是内容为空,有哪位知道是什么原因么? btw:我是在windows下设计这个程序的 代码 # !/usr/bin/env python # coding=utf-8 from subprocess import Popen, PIPE import re def disk_space(pattern = " 2[0-9]% " , message = " CAPACITY WARNING " ): # # take shell command output ps = Popen( " df -h " , shell = True, stdout = PIPE, stderr = PIPE) output_lines = ps.stdout.readlines() for line in output_lines: line = line.strip() if re.search(pattern, line): print " %s %s " % (message, line) if

字节流-FileOutputStream、FileInputStream-读写

☆樱花仙子☆ 提交于 2020-01-17 23:56:07
向磁盘写入文件: 以utf-8编码写入文件: FileOutputStream fos = new FileOutputStream("D:/"+fileName+".json");//文件不存在会自动创建 OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); osw.write(beans);//string类型的对象 osw.flush(); 读取写入的文件: FileInputStream fis = new FileInputStream("test.txt"); InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); BufferedReader br = new BufferedReader(isr); String line = null; while ((line = br.readLine()) != null) { FileContent += line; FileContent += "\r\n"; // 补上换行符 } 来源: CSDN 作者: 不努力,谁会可怜你? 链接: https://blog.csdn.net/qq_32603969/article/details/104020324