# 大小写显示方式
name = "abcd"
print(name.title())
print(name.upper())
print(name.lower())
#合并(拼接字符串)
first_name = "wendy"
last_name = "xu"
full_name = first_name + " " + last_name
message = "Hello, " + full_name.title() + "!"
print(message)
# 制表符\t 换行符 \n
print("\tPython\n\tJava")
#删除字符串末尾的空白rstrip() 删除字符串开头空白 lstrip() 同时删除字符串两端的空白 strip()
username = " admin "
username = username.strip()
print(username)
#动手试一试
famous_person = "\tAlbert\n\tEinstein"
message = "Hello " + famous_person + ",would you like to learn some Python today?"
print(message)
print(famous_person.lower())
print(famous_person.upper())
print(famous_person.title())
message2 = famous_person + " once said, \"A person who never made a mistake never tried anything new\""
print(famous_person)
print(famous_person.lstrip())
print(famous_person.rstrip())
print(famous_person.strip())
# date : 2019-6-28
# author : Wendy
#数字
age = 23
message = "Happy" + str(age) + "rd Birthday"
print(message)
#动手试一试
a = 4 + 4
b = 10 - 2
c = 2 * 4
d = 16 / 2
print(a)
print(b)
print(c)
print(int(d))
num = 3
message = " My favouriate number is " + str(num)
print(message)
Python编程:从入门到实践 埃里克马瑟斯 1-2章
最新推荐文章于 2024-07-11 12:30:12 发布