Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将文件上载到jupyter时忽略ds_存储文件的建议_Python_Pandas - Fatal编程技术网

Python 将文件上载到jupyter时忽略ds_存储文件的建议

Python 将文件上载到jupyter时忽略ds_存储文件的建议,python,pandas,Python,Pandas,我想知道是否有人对如何处理苹果在上传数据时为每个文件夹自动创建的ds.store文件有一些建议。是否每个人都只写一个if语句: for i in files: if file == '.DS_Store' continue upload file... 或者有更好的方法吗?如果要确保跳过所有隐藏文件,请使用类似filename.startswith('.')如果要确保跳过所有隐藏文件,请使用类似filename.startswith('.')的方法,您必须忽略

我想知道是否有人对如何处理苹果在上传数据时为每个文件夹自动创建的ds.store文件有一些建议。是否每个人都只写一个if语句:

 for i in files:
    if file == '.DS_Store'
       continue

    upload file...

或者有更好的方法吗?

如果要确保跳过所有隐藏文件,请使用类似
filename.startswith('.')
如果要确保跳过所有隐藏文件,请使用类似
filename.startswith('.')
的方法,您必须忽略或跳过所有隐藏文件 假设要忽略以以下开头的所有文件:

import os


root = "/Users/yourname/Desktop/py scripts"
for item in os.listdir(root):
if not item.startswith('.') and os.path.isfile(os.path.join(root, item)):
 print item

您必须忽略或跳过所有隐藏的文件 假设要忽略以以下开头的所有文件:

import os


root = "/Users/yourname/Desktop/py scripts"
for item in os.listdir(root):
if not item.startswith('.') and os.path.isfile(os.path.join(root, item)):
 print item

文件是
.DS\u Store
文件是
.DS\u Store