阿尔及利亚手机号码套餐
python-algerian-mobile-phone-number的Python项目详细描述
Python阿尔及利亚手机号码套餐
这个包提供了几种处理阿尔及利亚电话号码的方法。在
这个软件包的目标是在阿尔及利亚创建一个python社区,并提供所有可能的库,使python框架和项目(如Django或Flask)适应阿尔及利亚市场并易于使用。在
灵感来自Mohamed Cherif Bouchelaghem所著的PHP Package。在
安装
使用包管理器pip安装Python阿尔及利亚移动电话号码包。在
pip install python-algerian-mobile-phone-number
用法:
实例化:
创建类AlgerianMobilePhoneNumber的实例,并将电话号码值作为属性传递
- 进口
phoneNumber=AlgerianMobilePhoneNumber('0770000000')
或者:
phoneNumber=AlgerianMobilePhoneNumber('07 70 00 00 00')
或者:
phoneNumber=AlgerianMobilePhoneNumber('07-70-00-00-00')
NOTE: For now only space and hyphens "-" separated numbers are accepted.
NOTE: International phone indicative such 00213 or +213 are accepted.
API:
str
要获取实例的字符串表示形式,请使用内置函数\uuu str_uu:
phoneNumber.__str__()#'0770000000'
等于
要比较两个电话号码:
other=AlgerianMobilePhoneNumber('0770000000')phoneNumber.equalsTo(other)#True
isMobilis、isjezzy和isOoredoo
查看移动电话号码提供商,包括Mobilis、Djezzy和Ooredo
phoneNumber=AlgerianMobilePhoneNumber('0770000000')phoneNumber.isMobilis()#FalsephoneNumber.isDjezzy()#TruephoneNumber.isOoredoo()#False
变更号
要更改实例的电话号码:
phoneNumber=AlgerianMobilePhoneNumber('0770000000')phoneNumber.changeNumber('0798000000')#'0798000000'
转换为国际
该方法接受一个名为prefix的参数——值仅为“00”和“+”
phoneNumber=AlgerianMobilePhoneNumber('0770000000')phoneNumber.convertToInternational()#'00213770000000'phoneNumber.convertToInternational('00')#'00213770000000'phoneNumber.convertToInternational('+')#'+213770000000'
转换器本地
该方法将internaltionl编号转换为本地编号。接受“00213”和“+213”
phoneNumber=AlgerianMobilePhoneNumber('00213770000000')phoneNumber.convertToLocal()#'0770000000'
NOTE: convertToInternational and convertToLocal does not change the number instance so you can assign it to a variable. If you want to change the class instance use changeNumber instead to avoid mistakes.
贡献
欢迎捐款,以提供最好的一揽子计划。在
- 克隆回购:
$ git clone git@github.com:mohamine18/python_algerian_mobile_phone_number.git
- 输入克隆的存储库目录。在
测试:
- 安装pytest:
$ pip install pytest
- 跑测试.py单元测试脚本:
$ pytest test.py
许可证
- 项目
标签: