python整数转换字符串_使用Python中的str()函数将整数值转换为字符串

python整数转换字符串

Given an integer value and we have to convert the value to the string using str() function.

给定一个整数值,我们必须使用str()函数将该值转换为字符串。

Python code to convert an integer value to the string value

Python代码将整数值转换为字符串值

# Python code to convert an integer value 
# to the string value

# integer value 
i_value = 12345

# converting to the string value
s_value = str(i_value)

# printing the integer & string values with their types
print("i_value: ", i_value)
print("type(i_value): ", type(i_value))

print("s_value: ", s_value)
print("type(s_value): ", type(s_value))

# another operation by multiplying the value 
print("i_value*4: ", i_value*4)
print("s_value*4: ", s_value*4)

Output

输出量

i_value:  12345
type(i_value):  
s_value:  12345
type(s_value):  
i_value*4:  49380
s_value*4:  12345123451234512345

Code explanation:

代码说明:

In the above code i_value is an integer variable contains an integer value, we are converting i_value to the string by using str() function and storing the result in

你可能感兴趣的:(字符串,python,java,c++,机器学习)