随笔分类 -  文心一言

摘要:from datetime import datetime, timedelta # 获取当前日期 today = datetime.today() # 获取前一天的日期 yesterday = today - timedelta(days=1) # 格式化日期为所需的字符串格式 date_str 阅读全文
posted @ 2023-11-08 22:51 西北逍遥 阅读(348) 评论(0) 推荐(0) 编辑
摘要:在Python中,可以使用os模块来遍历一个目录下的所有子目录和文件 import os def traverse_directory(path): for root, dirs, files in os.walk(path): level = root.replace(path, '').coun 阅读全文
posted @ 2023-10-03 07:27 西北逍遥 阅读(81) 评论(0) 推荐(0) 编辑
摘要:在Python中拷贝文件可以使用shutil模块 import shutil # 源文件路径 src_file = '/path/to/source/file.txt' # 目标文件路径 dst_file = '/path/to/destination/file.txt' # 使用shutil模块的 阅读全文
posted @ 2023-10-01 12:33 西北逍遥 阅读(41) 评论(0) 推荐(0) 编辑
摘要:拷贝整个目录及其子目录和文件,可以使用shutil.copytree()函数。 import shutil # 源目录路径 src_dir = '/path/to/source/directory' # 目标目录路径 dst_dir = '/path/to/destination/directory 阅读全文
posted @ 2023-09-30 17:51 西北逍遥 阅读(345) 评论(0) 推荐(0) 编辑
摘要:from datetime import datetime # 获取当前时间 now = datetime.now() # 获取年、月、日、时、分、秒和毫秒 year = now.year month = now.month day = now.day hour = now.hour minute 阅读全文
posted @ 2023-09-29 20:17 西北逍遥 阅读(967) 评论(0) 推荐(0) 编辑
摘要:在Python中,可以使用os模块的rename()函数来重命名文件。以下是一个基本的示例: import os # 原文件的路径 old_file_path = '/path/to/your/old_file_name.txt' # 新文件的路径 new_file_path = '/path/to 阅读全文
posted @ 2023-09-28 21:13 西北逍遥 阅读(75) 评论(0) 推荐(0) 编辑
摘要:在C++中启动一个.bat文件,你可以使用标准库中的system函数。这个函数可以让你在C++程序中执行外部命令。 #include <cstdlib> int main() { // 在这里替换成你的.bat文件的路径 const char* batchFilePath = "C:\\Path\\ 阅读全文
posted @ 2023-09-27 11:11 西北逍遥 阅读(638) 评论(0) 推荐(0) 编辑
摘要:pip install pandas openpyxl 读取Excel文件 import pandas as pd # 读取Excel文件 df = pd.read_excel('your_file.xlsx') # 查看数据 print(df) 写入Excel文件 import pandas as 阅读全文
posted @ 2023-09-26 08:55 西北逍遥 阅读(32) 评论(0) 推荐(0) 编辑
摘要:from PyQt5.QtCore import QThread, pyqtSignal import time class MyThread(QThread): finished = pyqtSignal() def run(self): print('Thread started.') time 阅读全文
posted @ 2023-09-25 16:52 西北逍遥 阅读(17) 评论(0) 推荐(0) 编辑
摘要:当使用Python的requests.post函数时,可以在其中添加异常处理来捕获可能的网络错误或HTTP错误。以下是一个示例代码,演示如何使用try-except语句来处理requests.post可能抛出的异常: import requests url = 'http://cbim.com/up 阅读全文
posted @ 2023-09-11 17:08 西北逍遥 阅读(516) 评论(0) 推荐(0) 编辑
摘要:在PyQt中,可以使用matplotlib库来绘制折线图并设置y轴的最大最小值。 import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget from matplotlib.figure 阅读全文
posted @ 2023-09-10 13:47 西北逍遥 阅读(165) 评论(0) 推荐(0) 编辑
摘要:使用 requests 库可以方便地上传多个文件和其他字段。当使用Python的requests.post函数时,您可以在其中添加异常处理来捕获可能的网络错误或HTTP错误。 import requests url = 'http://cbim.com/upload' files = {'file1 阅读全文
posted @ 2023-09-05 12:53 西北逍遥 阅读(335) 评论(0) 推荐(0) 编辑
摘要:微信小程序下拉重新请求数据 Page({ data: { // 页面数据 }, onPullDownRefresh: function () { // 请求数据 this.getData() }, getData: function () { // 发送网络请求获取数据 // ... // 请求成功 阅读全文
posted @ 2023-09-01 13:55 西北逍遥 阅读(54) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示