message = "Hello Python World!"
print(message)
message = "Hello Python Crash Course world!"
print(message)
msg = 'I told my friend, "Python is my favorite"'
print(msg)
msg = "I told my friend, 'Python is my favorite'"
print(msg)
msg = "I told my friend, \"Python is my favorite\""
print(msg)
name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
first_name = "ada"
last_name = "lovelace"
full_name = first_name +" "+last_name
print(full_name)
message = "Hello, " +full_name.title()+"!"
print(message)
print("Python")
print("\tPython")
print("Languages:\nPython\nC\nJavaScript")
print("Languages:\n\tPython\n\tC\n\tJavaScript")
#空白操作
favorite_language = ' python '
print("oo"+favorite_language+"hello")
print("oo"+favorite_language.rstrip()+"hello")
print("oo"+favorite_language.lstrip()+"hello")
print("oo"+favorite_language.strip()+"hello")
print("oo"+favorite_language+"hello")
message = "One of Python's strengths is its diverse community."
print(message)
name = "Hello Eric, would you liketo learn some Python today?"
print(name)
name = "PiaoYongyou"
print(name.lower())
print(name.upper())
print(name.title())
print('Albert Einstein once said,"Apersonwho never madea mistake never tried anything new."')
famouse_person="Albert Einstein"
message = "Apersonwho never madea mistake never tried anything new."
print(famouse_person+" once said,\""+message+"\"")
name = ' Piao\nYong\tyou '
print("name:"+name+".")
print("name:"+name.lstrip()+".")
print("name:"+name.rstrip()+".")
print("name:"+name.strip()+".")
本文通过一系列Python代码示例,展示了字符串操作、变量赋值、打印输出等基础语法,适合初学者快速掌握Python编程语言的基本用法。
3050

被折叠的 条评论
为什么被折叠?



