1 #捕获异常 2 import urllib.request 3 import urllib.error 4 5 try: 6 response = urllib.request.urlopen('http://sasd.com') 7 except urllib.error.URLError a... ...
分类:
Web程序 时间:
2017-05-11 19:45:33
阅读次数:
170
python os模块的主要用法python中的os模块可以用来编写于平台无关的一些文件系统操作。主要的方法如下:一些标记属性os.linesep 文件中分割行的字符串os.sep文件路径名的分隔符os.curdir当前工作目录的字符串名称os.pardir父目录字符串名称常用方法os.remove ...
分类:
编程语言 时间:
2017-05-06 10:13:50
阅读次数:
198
12.7 取消一个线程 有时,想让一个线程能够要求还有一个线程终止,就像给它发送一个信号一样。线程有方法能够做到这一点,与与信号处理一样。线程能够被要求终止时改变其行为。 pthread_cancel是用于请求一个线程终止的函数: #inlude <pthread.h> int pthread_ca ...
分类:
编程语言 时间:
2017-04-27 10:13:49
阅读次数:
156
#include #include #include #include int getFileNum(char* root){ //open dir DIR* dir = NULL; dir = opendir(root); if(dir == NULL){ perror("opendir"); e... ...
分类:
其他好文 时间:
2017-04-23 21:35:36
阅读次数:
203
管道(pipe)是进程间通信的一种方式,DEMO如下: 管道的特点: 1. 管道是半双工的(数据只能在一个方向上流动) 2. 管道只能在具有公共祖先的两个进程之间使用 对于从父进程到子进程的管道,父进程关闭管道的读端fd[0],子进程关闭写端fd[1]。 对于从子进程到父进程的管道,父进程关闭fd[ ...
分类:
系统相关 时间:
2017-03-14 10:34:36
阅读次数:
162
部分名词解释: 文件描述符: 文件描述符(file descriptor) 通常是一个小的非负整数,内核用以标识一个特定进程正在访问的文件,当内核打开一个现有文件或创建一个新文件时,它都返回一个文件描述符。 在读、写文件时,可以使用这个文件描述符; root@aiyq195:/home/aiyq19 ...
分类:
其他好文 时间:
2017-02-28 13:26:05
阅读次数:
528
1.创建一个新文件,创建新文件除了可以使用open函数之外还可以用creat()函数。 创建文件函数 creat(const char * pathname, mode_t mode) 头文件 :#include <fcntl.h> 参数说明:第一个参数pathname同open函数的第一个参数具有 ...
分类:
其他好文 时间:
2017-02-19 23:45:17
阅读次数:
200
1 #include 2 #include 3 #include 4 #include 5 6 #define DEV_NAME "/dev/my_led" 7 8 int main(int argc, char const *argv[]) 9 { 10 11 int fd = open(DEV_... ...
分类:
移动开发 时间:
2017-02-19 18:04:00
阅读次数:
210
SIGCHLD的产生条件 1、子进程终止时 2、子进程接收到SIGSTOP信号停止时 3、子进程处在停止态,接受到SIGCONT后唤醒时 ...
分类:
其他好文 时间:
2017-02-17 12:48:13
阅读次数:
231
1.错误处理 - fprintf() - perror() 2.通用I/O模型 - fd = open(pathname, flags, mode) - numread = read(fd, buffer, count) - numwritten = write(fd, buffer, count) ...