linux 中解析命令行参数(getopt_long用法) http://www.educity.cn/linux/518242.html 详细解析命令行的getopt_long()函数 http://www.codeweblog.com/%E8%AF%A6%E7%BB%86%E8%A7%A3%E6%9E%90%E5%91%BD%E4%BB%A4%E8%A1%8C%E7%9A%84getopt_long-%E5%87%BD%E6%95%B0/ C/C++中有哪些简单好用的命令行参数解析工具? h
Linux open函数 open 函数用于打开和创建文件.以下是 open 函数的简单描述 #include <fcntl.h> int open(const char *pathname, int oflag, ... ); 返回值:成功则返回文件描述符,否则返回 -1 对于 open 函数来说,第三个参数(...)仅当创建新文件时才使用,用于指定文件的访问权限位(access permission bits).pathname 是待打开/创建文件的路径名(如 C:/cpp/a.cpp):
Linux open函数 open 函数用于打开和创建文件.以下是 open 函数的简单描述 #include <fcntl.h> int open(const char *pathname, int oflag, ... ); 返回值:成功则返回文件描述符,否则返回 -1 对于 open 函数来说,第三个参数(...)仅当创建新文件时才使用,用于指定文件的访问权限位(access permission bits).pathname 是待打开/创建文件的路径名(如 C:/cpp/a.cpp):
读文件: 读取文件 f = open('\info.txt') fil = f.read() f.close() 按行读文件: f = open("info.txt") while 1: line = f.readline() line=line.strip('\n') # 去掉换行符 if not line: break print line f.close()
3.学会使用一些管理命令 ps/top/lsof/netstat/kill/tcpdump/iptables/dd 端口查看 ps -- process status ps aux 观察程序所有程序资料 ps l 显示程序 uid pid ppid 等内容 ps AI 显示所有程序 的uid pid ppid top -- display and update sorted information about processes 不用多说,这个命令观察系统信息进程 top -b -n 2 >
项目情景描述: 在restful架构风格的项目交付测试的过程中,某接口出现 请求超时导致的http 502 Bad Gateway,于是开始排查具体是接口函数中的哪行代码或函数 响应时间过长导致的502错误. 刚开始的解决方法: 土鳖式的导入 time模块进行时间计算,从而查出具体响应时间过长的位置 如下: import time import time from flask import Flask app = Flask(__name__) app.route('/line_test') d