[英]Can not print out the filename when the directory is too long by using python
I used python to print out the filename in a certain directory. 我使用python在某个目录中打印出文件名。 But when the directory is too long the output comes out an empty matrix.
但是当目录太长时,输出结果将为空矩阵。
#This code outputs the correct filename: #此代码输出正确的文件名:
import globpr int glob.glob("D:\\One\\Two\\Three\\Four\\*.dcm")
The output here is the exact the filename under in the directory. 此处的输出与目录下的文件名完全相同。 However, when it get to a sub-directory beyond this, it generates an error.
但是,当到达该目录以外的子目录时,将产生错误。
#This code generates an empty matrix: #此代码生成一个空矩阵:
import globpr int glob.glob("D:\\One\\Two\\Three\\Four\\Five\\*.dcm")
The output here is an empty matrix. 这里的输出是一个空矩阵。 Any help thank you
任何帮助谢谢
Any suggested help please? 有什么建议的帮助吗?
Escape your backslashes. 转义您的反斜杠。 You've stumbled upon an escape sequence.
您偶然发现了转义序列。
glob.glob('c:\\real\\path\\here\\*.dcm')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.