打印
print("my name is zhoul")
变量赋值
message = "my sex is male"
print(message)
message = "my favorite is lol"
print(message)
字符串,双引号和单引号的使用
>>> message = ‘‘‘my name is zhoule and
... my sex is male and
... my told my friend,"python is one of my favorite language"‘‘‘
对字符串操作的常用函数
>>> print(message.title())
My Name Is Zhoule And
My Sex Is Male And
My Told My Friend,"Python Is One Of My Favorite Language"
print(message.upper())
print(message.lower())
合并拼接字符串
print("hello " + message)
message = "hello " + message
print(message)
添加空白
制表符 \t
换行符 \n
删除空白
rstrip() 删除字符末尾空白
lstrip() 删除字符开头空白
strip() 删除字符两端空白
数字类型
整数和浮点数
做字符拼接时,可以用str(数字参数)将数字转换为字符,要不会报错
注释
与shell一样用#
python之禅
import this
原文:http://www.cnblogs.com/zhoujialele/p/6444907.html