
代码片段
零K沁雪
这个作者很懒,什么都没留下…
展开
-
C 清空一个已经打开的文件
记录 2 个 C 函数,这2个函数是用来截断一个文件的int truncate(const char *path, off_t length);int ftruncate(int fd, off_t length);truncate:/**path : 文件路径length : 截断的长度,设为 0 则可以清空文件。 若 length 大于文件大小,则文件被扩充,扩充部分用 '\0' 填充**/int truncate(const char *path, of原创 2022-02-15 13:38:00 · 1495 阅读 · 0 评论 -
爬取 ZOL 壁纸
代码写于#!/usr/bin/env python3# -*- coding: utf-8 -*-# 开发时间 : 2021/6/2 15:02# 文件名称 : zolWallpaper.py# 开发工具 : PyCharmimport osimport requestsimport urllib.errorimport urllib.requestfrom bs4 import BeautifulSoupdef get_html(url): he..原创 2021-06-02 16:07:57 · 266 阅读 · 0 评论 -
Linux 获取网卡流量
#define _GNU_SOURCE /* To get defns of NI_MAXSERV and NI_MAXHOST */#include <arpa/inet.h>#include <sys/socket.h>#include <netdb.h>#include <ifaddrs.h>#include <...原创 2019-10-11 10:45:00 · 458 阅读 · 1 评论