name = (" Donald Trump \n")
print(name) # print the name
print(name.lstrip()) # print without the spaces in the left
print(name.rstrip())
print(name.strip())
代码2如下:
str = "python"
print(str.lower())
print(str.upper())
print(str.title())
'''
comments:
the program will print
the str in three formats.
'''
2-11 Python之禅: 在Python终端会话中执行命令import this ,并粗略地浏览一下其他的指导原则。
以下是在python终端会话中进行的:
C:\Users\hasee>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!