Python3基础 int()把合格字符串转化成整数,,镇场诗:    诚听


镇场诗:
    诚听如来语,顿舍世间名与利。愿做地藏徒,广演是经阎浮提。
    愿尽吾所学,成就一良心博客。愿诸后来人,重现智慧清净体。
——————————————————————————————————————————

ex1:
  code:

myStrOfTrue=‘1‘print(int(myStrOfTrue))


  result:

============= RESTART: C:/Users/Administrator/Desktop/mytest.py =============1>>> 

ex2:

  code:

myStrOfFalse=‘abc‘print(int(myStrOfFalse))

  result:

============= RESTART: C:/Users/Administrator/Desktop/mytest.py =============Traceback (most recent call last):  File "C:/Users/Administrator/Desktop/mytest.py", line 2, in <module>    print(int(myStrOfTrue))ValueError: invalid literal for int() with base 10: ‘abc‘>>> 


——————————————————————————————————————————
博文的精髓,在技术部分,更在镇场一诗。Python版本3.5,系统 Windows7。
Python是优秀的语言,值得努力学习。我是跟着小甲鱼视频教程学习的,推荐。
我是一个新手,所以如果博文的内容有可以改进的地方,甚至有错误的地方,请留下评论,我一定努力改正,争取成就一个良心博客。
注:此文仅作为科研学习,如果我无意中侵犯了您的权益,请务必及时告知,我会做出改正。

Python3基础 int()把合格字符串转化成整数

评论关闭