Python 字符串转换为整形和浮点类型的方法

作者:在奋斗的大道 时间:2021-09-02 00:09:31 

Python2.6 之前:字符串转换为整形和浮点型


>>>import string

>>>string.atoi('34.1')

34

>>>string.atof(‘34.1')

34.1

python2.6之后:字符串转换为整形和浮点型


>>>import string

>>>int('34.1')

34

>>>float('34.1')

34.1

来源:https://blog.csdn.net/zhouzhiwengang/article/details/72420544

标签:Python,字符串,整形,浮点
0
投稿

猜你喜欢

  • python神经网络Keras实现LSTM及其参数量详解

    2023-02-09 14:02:22
  • 轻松读懂Golang中的数组和切片

    2024-02-07 16:25:48
  • PHP排序二叉树基本功能实现方法示例

    2023-07-10 04:45:53
  • flask-restful使用总结

    2023-02-10 13:24:21
  • python使用xmlrpclib模块实现对百度google的ping功能

    2023-05-06 19:02:21
  • pycharm 2021.3最新激活码有效期至2100年(亲测可用)

    2022-03-23 13:45:03
  • ​​​​​​​如何利用python破解zip加密文件

    2022-11-27 17:51:30
  • go语言中的return语句

    2024-05-28 15:22:09
  • 计算机管理服务中找不到mysql的服务的解决办法

    2024-01-26 03:31:34
  • php中重定向网页跳转方法总结案例教程

    2023-06-11 20:47:18
  • 学习ASP.NET八天入门:第七天

    2007-08-07 13:52:00
  • Python数据类型转换详解

    2021-03-04 04:11:13
  • python类的方法属性与方法属性的动态绑定代码详解

    2023-07-02 03:31:26
  • 响应浏览器地址栏#(hash/fragment)变化

    2009-12-28 10:45:00
  • python面向对象之类的继承详解

    2022-03-20 18:22:22
  • 960 时代的终结

    2011-01-11 19:24:00
  • python实现生成字符串大小写字母和数字的各种组合

    2021-02-09 07:33:00
  • python根据unicode判断语言类型实例代码

    2021-08-22 18:24:04
  • 第一篇初识bootstrap

    2024-04-28 09:41:01
  • 利用python爬取有道词典的方法

    2021-07-08 04:42:05
  • asp之家 网络编程 m.aspxhome.com