FileFormat[source]
试图决定 Import 应该用什么格式来导入对应于名称 source 的文件.
FileFormat[source,{"fmt1","fmt2",…}]
返回可用于导入 source 的第一个 "fmti".
FileFormat[source]
试图决定 Import 应该用什么格式来导入对应于名称 source 的文件.
FileFormat[source,{"fmt1","fmt2",…}]
返回可用于导入 source 的第一个 "fmti".
更多信息和选项
- FileFormat 返回 Import 采用类型的格式名称.
- 在 FileFormat[source,…] 中,source 可为以下任意内容:
-
"file" or File["file"] 在 $Path 上搜索的文件名 "url" or URL["url"] HTTP, HTTPS 或 FTP URL CloudObject[…] 云对象 LocalObject[…] 本地对象 DataConnectionObject[…] 连接对象 - FileFormat 采用启发式方法,可能得不到正确的结果,特别是较短的文件.
- 如果应用于 source,FileFormat 不会验证 Import 是否成功.
- FileFormat 从文件系统中的文件的名称和属性获得信息,但依据最终的结果将只返回文件的实际内容.
- 可指定以下选项:
-
MaxItems Automatic 最多返回多少项 - FileFormat[url] 接受以下 URLDownload 选项:
-
Authentication None 要发送的认证信息 CookieFunction Automatic 对收到的 cookie 应用的函数 ConnectionSettings Automatic 连接的速度和其他设置 FollowRedirects True 是否遵循 HTTP 重定向 Interactive True 是否允许交互式认证对话框 TimeConstraint Infinity 等待响应的时间 VerifySecurityCertificates True 是否验证 SSL 安全证书
范例
打开所有单元 关闭所有单元范围 (8)
源 (4)
确定文件的 Import 格式:
FileFormat 给出 Import 使用的格式名称:
确定 URL 的 Import 格式:
确定 DataConnectionObject 的 Import 格式:
格式 (4)
属性和关系 (2)
FileFormat 将该列表用作猜测起点:
可以创建扩展名不正确的文件. 如创建一个扩展名为 .jpg 的 PNG 文件:
FileNameToFormatList 仅查看文件名称:
FileFormat 使用更为复杂的试探法来确定正确格式:
可能存在的问题 (1)
FileFormat 使用启发式方法,结果可能并不总是准确的,例如,对 "MBOX" 文件给出 "CSV":
相关指南
-
▪
- 导入和导出 ▪
- 连接列表 ▪
- 互联网和计算机系统数据 ▪
- 文件操作 ▪
- 云函数和部署
文本
Wolfram Research (2007),FileFormat,Wolfram 语言函数,https://reference.wolfram.com/language/ref/FileFormat.html (更新于 2025 年).
CMS
Wolfram 语言. 2007. "FileFormat." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/FileFormat.html.
APA
Wolfram 语言. (2007). FileFormat. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/FileFormat.html 年
BibTeX
@misc{reference.wolfram_2025_fileformat, author="Wolfram Research", title="{FileFormat}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/FileFormat.html}", note=[Accessed: 12-April-2026]}
BibLaTeX
@online{reference.wolfram_2025_fileformat, organization={Wolfram Research}, title={FileFormat}, year={2025}, url={https://reference.wolfram.com/language/ref/FileFormat.html}, note=[Accessed: 12-April-2026]}