3 回答
TA贡献1752条经验 获得超4个赞
1,整数字符串转换为对应的整数
int('12')
2,小数字符串转换为对应小数
float('12.34')
3,数字转换为字符串
str(123.45)
4,ASCII码转换为相应字符
chr(97)
5,字符转换为响应ASCII码
ord('a')
TA贡献1895条经验 获得超3个赞
str1=""
str_list=[]
for i in range(5):
N=input("please enter the number:")
str1+=str(N)
str_list.append(str(N))
print str1
print str_list
TA贡献1816条经验 获得超4个赞
以下代码调试通过:
1 2 3 4 5 6 7 | l = []
for i in range(5): n = input("please enter the number:") l.append(n)
print('l:', l) |
运行效果:
1 2 3 4 5 6 7 8 | please enter the number:12 please enter the number:34 please enter the number:56 please enter the number:35 please enter the number:22 l: ['12', '34', '56', '35', '22']
Process finished with exit code 0 |
添加回答
举报
