You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
import os
|
|
|
|
# 测试文件路径
|
|
input_file = r'D:\计量经济学\计量实验资料及作业要求\计量实验资料及作业要求\图文帖子实验数据(新).xlsx'
|
|
output_file = r'D:\计量经济学\计量实验资料及作业要求\计量实验资料及作业要求\UGC回归数据.xlsx'
|
|
|
|
print("========================================")
|
|
print(" 测试文件访问")
|
|
print("========================================")
|
|
print(f"当前目录: {os.getcwd()}")
|
|
print()
|
|
|
|
# 检查输入文件
|
|
print("检查输入文件:")
|
|
print(f"路径: {input_file}")
|
|
print(f"存在: {os.path.exists(input_file)}")
|
|
if os.path.exists(input_file):
|
|
print(f"大小: {os.path.getsize(input_file) / 1024:.2f} KB")
|
|
else:
|
|
print("文件不存在!")
|
|
|
|
# 检查输出文件
|
|
print("\n检查输出文件:")
|
|
print(f"路径: {output_file}")
|
|
print(f"存在: {os.path.exists(output_file)}")
|
|
if os.path.exists(output_file):
|
|
print(f"大小: {os.path.getsize(output_file) / 1024:.2f} KB")
|
|
else:
|
|
print("文件不存在!")
|
|
|
|
# 检查目录
|
|
print("\n检查目录:")
|
|
dir_path = os.path.dirname(input_file)
|
|
print(f"目录: {dir_path}")
|
|
print(f"存在: {os.path.exists(dir_path)}")
|
|
if os.path.exists(dir_path):
|
|
print("目录内容:")
|
|
files = os.listdir(dir_path)
|
|
for file in files[:10]: # 只显示前10个文件
|
|
file_path = os.path.join(dir_path, file)
|
|
size = os.path.getsize(file_path) / 1024
|
|
print(f" {file}: {size:.2f} KB")
|
|
if len(files) > 10:
|
|
print(f" ... 还有 {len(files) - 10} 个文件")
|
|
|
|
print()
|
|
print("========================================")
|
|
print(" 测试完成")
|
|
print("========================================")
|
|
|