python怎么把字符串转换成数字
答案:3 悬赏:0 手机版
解决时间 2021-02-06 20:23
- 提问者网友:咪咪
- 2021-02-06 10:25
python怎么把字符串转换成数字
最佳答案
- 五星知识达人网友:想偏头吻你
- 2021-02-06 11:53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Python 3.5.2(v3.5.2:4def2a2901a5, Jun 252016, 22:01:18) [MSC v.190032bit (Intel)] on win32
Type"help", "copyright", "credits"or"license"formore information.
>>> s1 ='123'
>>> s1
'123'
>>> i1 =int(s1)
>>> i1
123
>>> type(i1)
<class'int'>
>>> s2 ='123.4'
>>> f2 =float(s2)
>>> f2
123.4
>>> type(f2)
<class'float'>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Python 3.5.2(v3.5.2:4def2a2901a5, Jun 252016, 22:01:18) [MSC v.190032bit (Intel)] on win32
Type"help", "copyright", "credits"or"license"formore information.
>>> s1 ='123'
>>> s1
'123'
>>> i1 =int(s1)
>>> i1
123
>>> type(i1)
<class'int'>
>>> s2 ='123.4'
>>> f2 =float(s2)
>>> f2
123.4
>>> type(f2)
<class'float'>
全部回答
- 1楼网友:躲不过心动
- 2021-02-06 13:55
a="
- 2楼网友:第四晚心情
- 2021-02-06 13:20
a="整数字符串转换为对应的整数
int('12')
小数字符串转换为对应小数
float('12.34')
数字转换为字符串
str(123.45)
ASCII码转换为相应字符
chr(97)
字符转换为响应ASCII码
ord('a')
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯