阿尔及利亚手机号码套餐

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的实例,并将电话号码值作为属性传递

  • 进口
^{pr2}$
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

许可证

MIT License。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JavaFX SwingWorker等价物?   java如何检查一个字符串只包含数字和一个小数点?   java遇到了异常组织。阿帕奇。卡塔琳娜。LifecycleException:无法启动组件   java如何从日期格式获取最低计时单位?   java应用服务器与开发过程的集成   java我无法运行Junit测试   无法在java多线程处理中维护生产者任务的顺序   java如何在CLI应用程序中“拦截”Ctrl+C?   java如何使用JSch进行原子SFTP文件传输,以便在写入过程完成之前无法访问该文件?   java当用户摆弄html范围滑块时,如何更改内容(文本)?   如何在Java中向现有文件追加文本?   JUnit测试中的java模拟Apache驼峰位置   java Maven更新项目和依赖项