python把字符串转化为数字
时间: 2023-11-08 22:04:10 浏览: 116
在Python中,有几种方法可以将字符串转换为数字。其中,使用int()函数是一种常用的方法。当字符串只包含数字字符时,可以直接使用int()函数将其转换为整数。例如,假设有一个字符串str_num = "123",可以使用int()函数将其转换为整数num = int(str_num),结果为123。,结果为。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [【Python】python 字符串转数字](https://blog.csdn.net/qq_42810361/article/details/129843786)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [python中字符串转成数字的几种方法](https://blog.csdn.net/shannya_zhima/article/details/113730018)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文