type_conversion.py
来自「python编程很好的入门材料,包括讲义和源码.」· Python 代码 · 共 20 行
PY
20 行
#-------------------------------------------------------------------------------
# With out the explicit conversion, Python will automatically upgrade your
# addition to "floating-point" addition, which may not be what you want
# especially if your intention was to drop the decimal places.
#-------------------------------------------------------------------------------
myInt = 25
myFloat = 25.12
myString = "The value of 'myInt' is "
print myInt + myFloat
# With conversion - to int
print myInt + int( myFloat )
# With conversion - to string
print myString + str( myInt )
raw_input( "\nPress Enter to exit..." )
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?