Python 的 any(~)
方法返回一個布爾值,指示所提供的可迭代對象的任何元素是否為 true。
參數
1. iterable
| iterable
用於檢查真實元素的迭代。
返回值
一個布爾值,指示所提供的可迭代對象的任何元素是否為 true。如果 iterable 為空或 iterable 中的所有元素均為 false,則返回False
。
例子
基本用法
檢查列表 a
中的任何元素是否為 true:
a = ['hi', 'bye', 'see you']
any(a)
True
由於列表 a
中的所有元素均為 true,因此返回 True
。
檢查列表 b
中的任何元素是否為 true:
b = [0, False]
any(b)
False
列表 b
中的所有元素均為 false,因此返回 False
。
相關用法
- Python any用法及代碼示例
- Python any()用法及代碼示例
- Python NumPy any方法用法及代碼示例
- Python arcgis.gis._impl._profile.ProfileManager.save_as用法及代碼示例
- Python arcgis.raster.functions.ccdc_analysis用法及代碼示例
- Python arcgis.geometry.functions.trim_extend用法及代碼示例
- Python arcgis.raster.analytics.sample用法及代碼示例
- Python arcgis.features.analysis.derive_new_locations用法及代碼示例
- Python arcgis.features.analyze_patterns.calculate_density用法及代碼示例
- Python arcgis.geometry.Geometry.label_point用法及代碼示例
- Python ast.MatchClass用法及代碼示例
- Python arcgis.plan_routes用法及代碼示例
- Python arcgis.mapping.forms.FormInfo用法及代碼示例
- Python arcgis.gis.UserManager.get用法及代碼示例
- Python arcgis.raster.ImageryLayerCacheManager.update_tiles用法及代碼示例
- Python arcgis.geometry.Geometry.true_centroid用法及代碼示例
- Python arcgis.gis.User.generate_direct_access_url用法及代碼示例
- Python arcgis.gis.GroupMigrationManager.create用法及代碼示例
- Python arcgis.geometry.Geometry.hull_rectangle用法及代碼示例
- Python arcgis.features.analysis.summarize_within用法及代碼示例
- Python arcgis.geometry.filters.intersects用法及代碼示例
- Python arcgis.geometry.functions.project用法及代碼示例
- Python abc.ABCMeta用法及代碼示例
- Python arcgis.raster.functions.percentile用法及代碼示例
- Python arcgis.raster.ImageryLayer.save用法及代碼示例
注:本文由純淨天空篩選整理自Arthur Yanagisawa大神的英文原創作品 Python | any method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。