ascii
将 FTP 传输模式设置为 ASCII
说明
示例
使用 ASCII 传输模式从 FTP 服务器下载文本文件。
首先,连接到美国国家环境信息中心 (NCEI) 的 FTP 服务器。
ftpobj = ftp('ftp.ngdc.noaa.gov')
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/" CertificateFilename: "default" ConnectionTimeout: 5 min TransferTimeout: Inf sec
默认传输模式为二进制。下载文本文件时,您可以改用 ASCII 模式,以便换行符能够正确转换。
将传输模式设置为 ASCII。要显示当前传输模式,请显示 FTP 对象。
ascii(ftpobj) ftpobj
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "ascii" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/" CertificateFilename: "default" ConnectionTimeout: 5 min TransferTimeout: Inf sec
下载文本文件并断开连接。
mget(ftpobj,'README.txt');
close(ftpobj)
显示 README.txt
的开头。要读取下载到您计算机上的 README.txt
副本,请使用 fileread
函数。
readme = fileread('README.txt');
readme(1:95)
ans = ' Welcome to the NOAA/National Centers for Environmental Information (NCEI)'
FTP 服务由美国国家环境信息中心 (NCEI) 提供。有关 NCEI 服务条款,请参阅 NCEI 隐私政策、免责声明和版权。
输入参数
FTP 服务器连接,指定为 FTP 对象。
版本历史记录
在 R2006a 之前推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)