我有以下代码:
String base64 = "data:image/png;base64,iVBORw0KGgoAAAANSUh.....";
base64 = base64.substring(22, base64.length());
问题是我有20个if-check,我检查addSetting.Property。现在回答问题:
重构这些if语句的最佳和最有效的方法是什么?
答案 0 :(得分:1)
你可以使用adSetting.STUFF_AS_STRING - >获得20x2数组。 rc.RoleName mapping。
然后在for循环中遍历数组
伪代码:
C:\Users\Sayed>django-admin startproject pp
Traceback (most recent call last):
File "c:\python27\arcgis10.3\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\arcgis10.3\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\ArcGIS10.3\Scripts\django-admin.exe\__main__.py", line 9, in <module>
File "c:\python27\arcgis10.3\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
utility.execute()
File "c:\python27\arcgis10.3\lib\site-packages\django\core\management\__init__.py", line 302, in execute
settings.INSTALLED_APPS
File "c:\python27\arcgis10.3\lib\site-packages\django\conf\__init__.py", line 55, in __getattr__
self._setup(name)
File "c:\python27\arcgis10.3\lib\site-packages\django\conf\__init__.py", line 43, in _setup
self._wrapped = Settings(settings_module)
File "c:\python27\arcgis10.3\lib\site-packages\django\conf\__init__.py", line 99, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "c:\python27\arcgis10.3\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: Import by filename is not supported.