将字符串转换为 int 的简单方法 [英] Short way to convert string to int

查看:33
本文介绍了将字符串转换为 int 的简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常这样做是为了将字符串转换为整数:

I usually do this to convert string to int:

my_input = int(my_input)

但我想知道是否有一种不那么笨拙的方法,因为感觉有点长.

but I was wondering if there was a less clumsy way, because it feels kind of long.

推荐答案

my_input = int(my_input)

没有比使用 int 函数(如您所述)

There is no shorter way than using the int function (as you mention)

这篇关于将字符串转换为 int 的简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆