您的位置:首页 > 编程语言 > Python开发

Python--字符串和对象

2016-01-11 11:08 603 查看
1.常见python函数

[code] abs()
 max()
 min()
 pow()
 round()
 fabs()
 ceil()
 floor()
 exp()


2. 字符串和字符

[code]letter='A'
message=" good"


3.编码

1.ASCII码表

2.函数ord()和chr()

[code]>>>ch = 'a'
>>>ord(ch)
97
>>> chr(98)
'b'
>>>ord()
65
>>>


3.转义序列

print(” hello word jack’s “) 错误

print(” hello word \”jack’s\”“) 正确

[code]\b  退格
\t  制表符
\n  换行符
\f  换页符
\r  回车符
\\  反斜线
\'  单引号
\"  双引号


4.不换行打印

print(item , end = ” anyendingstring”)

5.函数 str

[code]>>> s = str(3.4) # Convert afloat to string
>>> s
'3.4'


6.字符串连接操作

可以用+来对两个数字进行加法,也可以连接两个字符串

7.从控制台读取字符串
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: