הודעה: כל הפרויקטים הלא מסחריים שנרשמו לשימוש ב-Earth Engine לפני
15 באפריל 2025 חייבים
לאמת את הזכאות לשימוש לא מסחרי כדי לשמור על הגישה. אם לא תאמתו את החשבון עד 26 בספטמבר 2025, יכול להיות שהגישה שלכם תושעה.
ee.Number.format
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Convert a number to a string using printf-style formatting.
| שימוש | החזרות |
|---|
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 Environment.
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 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[],[]]