ee.Number.format
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
printf-स्टाइल फ़ॉर्मैटिंग का इस्तेमाल करके, किसी संख्या को स्ट्रिंग में बदलता है.
इस्तेमाल | रिटर्न |
---|
Number.format(pattern) | स्ट्रिंग |
आर्ग्यूमेंट | टाइप | विवरण |
---|
यह: number | नंबर | वह संख्या जिसे स्ट्रिंग में बदलना है. |
pattern | स्ट्रिंग, डिफ़ॉल्ट: "%s" | printf-स्टाइल वाली फ़ॉर्मैट स्ट्रिंग. उदाहरण के लिए, '%.2f' से '3.14' जैसे फ़ॉर्मैट वाली संख्याएं मिलती हैं. वहीं, '%05d' से '00042' जैसे फ़ॉर्मैट वाली संख्याएं मिलती हैं. फ़ॉर्मैट स्ट्रिंग में ये शर्तें पूरी होनी चाहिए:
- शून्य या उससे ज़्यादा प्रीफ़िक्स वर्ण.
- सिर्फ़ एक '%' होना चाहिए.
- सेट [#-+ 0,(.\d] में शून्य या उससे ज़्यादा मॉडिफ़ायर वर्ण.
- सेट [sdoxXeEfgGaA] में सिर्फ़ एक कन्वर्ज़न वर्ण.
- शून्य या उससे ज़्यादा सफ़िक्स वर्ण.
फ़ॉर्मैट स्ट्रिंग के बारे में ज़्यादा जानने के लिए, https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html पर जाएं |
उदाहरण
कोड एडिटर (JavaScript)
print('Zero-fill to length of 3',
ee.Number(1).format('%03d')); // 001
print('Include 1 decimal place in 1.2347',
ee.Number(1.23476).format('%.1f')); // 1.2
print('Include 3 decimal places in 1.2347',
ee.Number(1.23476).format('%.3f')); // 1.235 (rounds up)
print('Scientific notation with 3 decimal places shown',
ee.Number(123476).format('%.3e')); // 1.235e+05 (rounds up)
print('Integer with 2 decimal places of precision',
ee.Number(123476).format('%.2f')); // 123476.00
Python सेटअप करना
Python API और इंटरैक्टिव डेवलपमेंट के लिए geemap
का इस्तेमाल करने के बारे में जानकारी पाने के लिए,
Python एनवायरमेंट पेज देखें.
import ee
import geemap.core as geemap
Colab (Python)
print('Zero-fill to length of 3:',
ee.Number(1).format('%03d').getInfo()) # 001
print('Include 1 decimal place in 1.2347:',
ee.Number(1.23476).format('%.1f').getInfo()) # 1.2
print('Include 3 decimal places in 1.2347:',
ee.Number(1.23476).format('%.3f').getInfo()) # 1.235 (rounds up)
print('Scientific notation with 3 decimal places shown:',
ee.Number(123476).format('%.3e').getInfo()) # 1.235e+05 (rounds up)
print('Integer with 2 decimal places of precision:',
ee.Number(123476).format('%.2f').getInfo()) # 123476.00
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[[["\u003cp\u003e\u003ccode\u003eNumber.format()\u003c/code\u003e converts Earth Engine Numbers to strings using printf-style formatting.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epattern\u003c/code\u003e argument accepts a format string, like '%.2f' for 2 decimal places or '%03d' for zero-padding to 3 digits.\u003c/p\u003e\n"],["\u003cp\u003eThis function allows customization of numeric output for display or further processing within Earth Engine scripts.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the Java Formatter documentation for details on available format string options and syntax.\u003c/p\u003e\n"]]],[],null,["# ee.Number.format\n\nConvert a number to a string using printf-style formatting.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------|---------|\n| Number.format`(`*pattern*`)` | String |\n\n| Argument | Type | Details |\n|----------------|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `number` | Number | The number to convert to a string. |\n| `pattern` | String, default: \"%s\" | A printf-style format string. For example, '%.2f' produces numbers formatted like '3.14', and '%05d' produces numbers formatted like '00042'. The format string must satisfy the following criteria: 1. Zero or more prefix characters. 2. Exactly one '%'. 3. Zero or more modifier characters in the set \\[#-+ 0,(.\\\\d\\]. 4. Exactly one conversion character in the set \\[sdoxXeEfgGaA\\]. 5. Zero or more suffix characters. For more about format strings, see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Formatter.html |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint('Zero-fill to length of 3',\n ee.Number(1).format('%03d')); // 001\n\nprint('Include 1 decimal place in 1.2347',\n ee.Number(1.23476).format('%.1f')); // 1.2\n\nprint('Include 3 decimal places in 1.2347',\n ee.Number(1.23476).format('%.3f')); // 1.235 (rounds up)\n\nprint('Scientific notation with 3 decimal places shown',\n ee.Number(123476).format('%.3e')); // 1.235e+05 (rounds up)\n\nprint('Integer with 2 decimal places of precision',\n ee.Number(123476).format('%.2f')); // 123476.00\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nprint('Zero-fill to length of 3:',\n ee.Number(1).format('%03d').getInfo()) # 001\n\nprint('Include 1 decimal place in 1.2347:',\n ee.Number(1.23476).format('%.1f').getInfo()) # 1.2\n\nprint('Include 3 decimal places in 1.2347:',\n ee.Number(1.23476).format('%.3f').getInfo()) # 1.235 (rounds up)\n\nprint('Scientific notation with 3 decimal places shown:',\n ee.Number(123476).format('%.3e').getInfo()) # 1.235e+05 (rounds up)\n\nprint('Integer with 2 decimal places of precision:',\n ee.Number(123476).format('%.2f').getInfo()) # 123476.00\n```"]]