line

Python 深究readline()

烈酒焚心 提交于 2020-03-25 20:53:02
文件123内容 123 456 789 操作: f = open('123','r') line = f.readline() print line[0] #1 print line[-1] #\n 回车 print line[1,-1] #23,注意从1 到-1 但是不包括line[-1],而包括开始位置line[1] 注意: f.readline()完成后最后一个字符是 ‘\n’,此时光标已经定位到了下一行的第0个位置 但是读第三行时 print line[-1]是9而不是'\n',因为此时最后一行不存在换行符 那么这样就好解决这个问题了:想在第一行后面加'hello',这样编程就错了: f = open('123','r+') f.readline() f.seek(-1,1) #定位到\n前 f.write('hello') f.close() 结果: 123 hello 789 没有在第一行写反到第二行了,这是因为原来的格局已定了,要想实现可以这样: f = open('123','r+') g = open('1234','w') line = f.readline() line = line[:-1] + ' hello\n' g.write() g.write(f.readline()) g.write(f.readline()) f.close() g.close

存储过程和函数 oracle

强颜欢笑 提交于 2020-03-24 18:47:21
3 月,跳不动了?>>> declare begin dbms_output.put_line('Hello World'); end; declare i number := 10; begin if i > 5 then dbms_output.put_line('OK'); end if; end; --loop循环 declare i number := 1; begin loop dbms_output.put_line('OK'); exit when i=10; i:=i+1; end loop; end; --while 循环 declare i number :=1; begin while i<10 loop dbms_output.put_line('我说了算'); i:=i+1; end loop; end; -- 1-100之间所有的偶数 declare i number := 1; begin while i <= 100 loop if mod(i, 2) = 0 then dbms_output.put_line(i); end if; i := i + 1; end loop; end; --智能循环 for循环 declare begin for i in 1 .. 10 loop dbms_output.put_line(i); end

批量修改文件名称

安稳与你 提交于 2020-03-18 21:27:54
3 月,跳不动了?>>> #-*-coding:utf-8-*- # 用法: # 先把pre改成自己作业里开始标号 # 文件路径path改成自己的 # 改完之后运行 # 运行是个无限循环,修改完一个图片名字后他会自动往后跳一个图片 # 每次修改只需要输入识别出的汉字即可修改。 # 例如图片17000.png。你只需要输入“惟”字即可,他会自动改成“惟17000.png”。修改完自动跳到下一个 import os import sys path = "D:/zhdan/ppyy/rename/data.txt" pathold = "D:/zhdan/ppyy/rename/old" pathnew = "D:/zhdan/ppyy/rename/old" #f = open(path,"r") #lines = f.readlines() #for line in lines # print(line) for line in open(path): str = [] str = line.replace('\n','').split(",") for i in range(4): try: if(i==0): newname = str[0] if(i==1): ###寻找文件在修改 oldname1 = str[1] newname1 = newname + "_1.jpg"

How can I represent a vector equation of a line segment in C++?

眉间皱痕 提交于 2020-03-16 05:55:42
问题 I am working with computer graphics. I would like to represent a line with two end points, and, then I would like my Line2d class to have a method that returns a Vector2d object. Suppose, I have the following classes: struct Point2d { int x; int y; }; Then, I can easily represent a line segment using two points: class LineSegment2d { private: Point2d start; Point2d end; public: ... ... }; According to the definition, a vector is composed of a magnitude and a direction. class Vector2d {

Shell脚本出现$'\\r': command not found

寵の児 提交于 2020-03-15 04:30:16
Centos7下执行shell脚本报错如下 [root@ip-172-29-10-16 ~]# sh install_zabbix_agent.sh install_zabbix_agent.sh: line 2: $'\r': command not found install_zabbix_agent.sh: line 8: $'\r': command not found install_zabbix_agent.sh: line 9: $'\r': command not found install_zabbix_agent.sh: line 10: syntax error near unexpected token `$'{\r'' 'nstall_zabbix_agent.sh: line 10: `install_zabbix(){ 原因 这是因为脚本文件可能在window弄过,有window下的空行,把他转换成unix格式的就行 解决办法 yum install dos2unix 然后再执行这个脚本就可以了 来源: https://www.cnblogs.com/lemon-le/p/10552581.html

日志文件C++ 时间 文件 行数

时光怂恿深爱的人放手 提交于 2020-03-14 04:09:47
#include <stdio.h> #include<windows.h> #include <time.h> #define Line __LINE__ #define File __FILE__ void WriteLog(const char *file, int line, char * msg) { SYSTEMTIME st; GetLocalTime(&st); FILE *fp; fp=fopen("D:\\log.txt","at"); fprintf(fp,"MyLogInfo: %d-%d-%d %d:%d:%d %s:%d: % s\n",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond, file,line, msg); printf(" %d-%d-%d %d:%d:%d %s:%d: %s\n",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond, file,line, msg); fclose(fp); // OutputDebugStringA(msg); } int main(int , char**) { WriteLog(File,Line, " now error...."); return 0; }

使用mac进行ios几种命令行打包方式

爱⌒轻易说出口 提交于 2020-03-13 11:06:13
随着ios平台的发展以及发布要求的多样性,测试的需求,自动打包可一定程度上提高效率。 自动打包的方式有如下几种: 一、使用xcodebuild进行打包 参考apple文档: https://developer.apple.com/library/prerelease/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html xcodebuild -project "${TARGET}.xcodeproj" -target ${TARGET} CODE_SIGN_IDENTITY="${IDENTITY}" clean //将project clean下 xcodebuild -workspace MyWorkspace.xcworkspace -scheme MyScheme archive //进行archive,生成xcarchive文件 xcodebuild -exportArchive -exportFormat IPA -archivePath MyMobileApp.xcarchive -exportPath MyMobileApp.ipa -exportProvisioningProfile 'MyMobileApp Distribution Profile' 上述红色背景的命令行

A+B for Input-Output Practice (V)

二次信任 提交于 2020-03-11 12:51:29
Problem Description Your task is to calculate the sum of some integers. Input Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. Output For each group of input integers you should output their sum in one line, and with one line of output for each line in input. Sample Input 2 4 1 2 3 4 5 1 2 3 4 5 Sample Output 10 15 # include <stdio.h> int main ( void ) { int t , n , number , s = 0 ; scanf ( "%d" , & t ) ; //数据组数 while ( t -- ) { s = 0 ; //总和归0 scanf ( "%d" , & n ) ; //数据个数 while ( n -- ) {

A+B for Input-Output Practice (V)

谁都会走 提交于 2020-03-11 09:50:25
Problem Description Your task is to calculate the sum of some integers. Input Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line. Output For each group of input integers you should output their sum in one line, and with one line of output for each line in input. Sample Input 2 4 1 2 3 4 5 1 2 3 4 5 Sample Output 10 15 Author lcy 代码: # include <stdio.h> int main ( ) { int a , b , n ; scanf ( "%d" , & n ) ; for ( int i = 0 ; i < n ; i ++ ) { scanf ( "%d" , & a ) ; int sum = 0 ; for ( int j = 0 ; j

Using R, how to calculate the distance from one point to a line?

只愿长相守 提交于 2020-03-10 17:18:09
问题 Suppose we have three points, a, b, c. b and c are linked to become a line. how to use R to calculate the distance from a to this line? Is there any function? Thanks a lot 回答1: It has to be distinguished whether we are dealing with a two-dimensional or a three-dimensional case. 2D case If the problem is two-dimensional, the position of the points a , b and c can be defined by pairs of numbers which represent the points' x and the y coordinates. The following function can be used to calculate