python - Google colab "glob.glob" 为什么找不到我的 1456 文件?
问题描述
为什么找不到我的 1456 文件?
import pandas as pd
import numpy as np
import sys
# uncommen the next row to install altair
# !{sys.executable} -m pip install altair vega_datasets
import altair as alt
import os
import copy
import glob
import matplotlib.pyplot as plt
from google.colab import drive
drive.mount('/content/drive')
path_files = r"/content/drive/MyDrive/BigData"
# All files ending with .txt
files = glob.glob("{}\*.txt".format(path_files))
print("Nombre de fichiers: {}".format(len(files)))
结果文件数:0
它必须找到1456个文件
解决方案
解决方案是:
所有以 .txt 结尾的文件
files = glob.glob(f"/content/gdrive/...../*.txt")
print("Nombre de fichiers: {}".format(len(files)))
推荐阅读
- java - 如何为不同于 exe 的文件夹添加上下文菜单项到 Windows 资源管理器
- random - 如何在 Crystal 中生成随机数?
- python - 气流触发 dag 故障
- ruby-on-rails - 您如何使用 ActiveRecord 从“created_at”按年份分组?
- php - “解析错误:无效的数字文字”php chr 039
- visual-studio-code - 如何在 vscode 中配置 Ctrl+PgUp 和 Ctrl+PgDown 键绑定导航到视图的顶部/底部而不是切换选项卡?
- applescript - 使用 Apple 脚本通过包标识符的给定包名称删除应用程序
- android - 数据重新绑定问题
- spring-boot - NumberFormatException 而 H2 db 在主键类型为字符串的表中插入
- java - gRPC 流被取消