当前位置:  开发笔记 > 开发工具 > 正文

phpfscanf()函数使用方法详解

phpfscanf()函数使用方法详解Thefscanf()functionparsestheinputfromanopenfileaccordingtothespecifiedformat.fscanf()函数的作用是:从文件中按照指定的格式输入">

  Definition and Usage

  定义和用法

  The fscanf() function parses the input from an open file according to the specified format.

  fscanf()函数的作用是:从文件中按照指定的格式输入。

  Syntax

  语法

  fscanf(file,format,mixed)

  Parameter参数Description描述

  fileRequired. Specifies the file to check

  必要参数。指定文件对象

  formatRequired. Specifies the format.

  必要参数。指定格式

  Possible format values:

  可用的格式值:

  %% - Returns a percent sign

  %% - 返回一个“%”

  %b - Binary number

  %b – 二进制数

  %c - The character according to the ASCII value

  %c – 某字符所对应的ASCII值

  %d - Signed decimal number

  %d – 包含正负号的十进制数(可包含正负数)

  %e - Scientific notation (e.g. 1.2e+2)

  %e – 科学技术符号(例如:1.2e+2)

  %u - Unsigned decimal number

  %u – 不包含正负号的十进制数

  %f - Floating-point number (local settings aware)

  %f – 浮点数字(本地属性)

  %F - Floating-point number (not local settings aware)

  %F – 浮点数字(非本地属性)

  %o - Octal number

  %o – 十进制数字

  %s - String

  %s – 字符串

  %x - Hexadecimal number (lowercase letters)

  %x – 十六进制数(小写字母)

  %X - Hexadecimal number (uppercase letters)

  %X – 十六进制数(大写字母)

  Additional format values. These are placed between the % and the letter (example %.2f):

  其它的文本格式值。它是位于%和字母之间的(如:%.2f):

  + (Forces both + and - in front of numbers. By default, only negative numbers are marked)

  +(在数字前面加上‘+’或‘-’来定义数字的正负性;默认情况下,正数不做标记)

  ' (Specifies what to use as padding. Default is space. Must be used together with the width specifier. Example: %'x20s (this uses "x" as padding)

  ’(指定使用旁白[padding]的类型。默认是空格space,它必须同时指定宽度,例如:%'x20s (这里使用 "x" 作为旁白[padding]) )

  - (Left-justifies the variable value)

  -(向左调整变量值)

  [0-9] (Specifies the minimum width held of to the variable value)

  [0-9](指定了变量值的最小宽度)

  .[0-9] (Specifies the number of decimal digits or maximum string length)

  .[0-9](指定了十位数字或最大字符串长度)

  Note: If multiple additional format values are used, they must be in the same order as above.

  注意:如果要使用多个上述的值,顺序必须按照上面的顺序,不能打乱。

  mixedOptional.

  可选参数

  Tips and Notes

  注意点

  Note: Any whitespace in the format string matches any whitespace in the input stream. This means that a tab (/t) in the format string can match a single space character in the input stream.

  注意:任何format的值中的空白部分[whitespace]与input内容相似;这意味着tab键(/t)[制表符]和input内容的一个单一的空格[space]相似。


推荐阅读
  • 资源推荐 | TensorFlow官方中文教程助力英语非母语者学习
    来源:机器之心。本文详细介绍了TensorFlow官方提供的中文版教程和指南,帮助开发者更好地理解和应用这一强大的开源机器学习平台。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 探讨一个显示数字的故障计算器,它支持两种操作:将当前数字乘以2或减去1。本文将详细介绍如何用最少的操作次数将初始值X转换为目标值Y。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • Android LED 数字字体的应用与实现
    本文介绍了一种适用于 Android 应用的 LED 数字字体(digital font),并详细描述了其在 UI 设计中的应用场景及其实现方法。这种字体常用于视频、广告倒计时等场景,能够增强视觉效果。 ... [详细]
  • RecyclerView初步学习(一)
    RecyclerView初步学习(一)ReCyclerView提供了一种插件式的编程模式,除了提供ViewHolder缓存模式,还可以自定义动画,分割符,布局样式,相比于传统的ListVi ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 本文详细介绍了如何在 Spring Boot 应用中通过 @PropertySource 注解读取非默认配置文件,包括配置文件的创建、映射类的设计以及确保 Spring 容器能够正确加载这些配置的方法。 ... [详细]
  • This document outlines the recommended naming conventions for HTML attributes in Fast Components, focusing on readability and consistency with existing standards. ... [详细]
  • 本文详细介绍了Java中org.w3c.dom.Text类的splitText()方法,通过多个代码示例展示了其实际应用。该方法用于将文本节点在指定位置拆分为两个节点,并保持在文档树中。 ... [详细]
  • 本文详细介绍了 Apache Jena 库中的 Txn.executeWrite 方法,通过多个实际代码示例展示了其在不同场景下的应用,帮助开发者更好地理解和使用该方法。 ... [详细]
  • 在现代网络环境中,两台计算机之间的文件传输需求日益增长。传统的FTP和SSH方式虽然有效,但其配置复杂、步骤繁琐,难以满足快速且安全的传输需求。本文将介绍一种基于Go语言开发的新一代文件传输工具——Croc,它不仅简化了操作流程,还提供了强大的加密和跨平台支持。 ... [详细]
  • 题目Link题目学习link1题目学习link2题目学习link3%%%受益匪浅!-----&# ... [详细]
  • 解决微信电脑版无法刷朋友圈问题:使用安卓远程投屏方案
    在工作期间想要浏览微信和朋友圈却不太方便?虽然微信电脑版目前不支持直接刷朋友圈,但通过远程投屏技术,可以轻松实现在电脑上操作安卓设备的功能。 ... [详细]
  • 网络运维工程师负责确保企业IT基础设施的稳定运行,保障业务连续性和数据安全。他们需要具备多种技能,包括搭建和维护网络环境、监控系统性能、处理突发事件等。本文将探讨网络运维工程师的职业前景及其平均薪酬水平。 ... [详细]
author-avatar
woshishl
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有