Python-程序语法 - Python注释&基本函数

Python注释

以# 为行开头为注释

相关函数

str()     --- 传入一个整型值,并求值为它的字符串形式
Python 2.7.17 (default, Mar  8 2023, 18:40:28)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> str(94343)
'94343'
>>> print('I am' + str(18) + 'Years old.')
I am18Years old.
>>> print('I am' +  str(18) + 'Years old.')
I am18Years old.
>>> print('I am ' + str(18) + ' Years old.')
I am 18 Years old.
>>>
int()  --- 与str()将输入值转换为字符串相反,int()函数将字符串数据作为输入,输出为整数!
>>> int(1234)
1234
>>> int(34)
34
>>> int(-9990)
-9990
float()  --- 将输入字符串求取浮点数形式的值
>>> float(1099)
1099.0
>>> float(-999)
-999.0
posted @ 2024-08-18 11:31  合滨  阅读(28)  评论(0编辑  收藏  举报