反斜扛“\”相关的一些用法,学习函数新的使用方法,如赋值给变量

print("让我们练习一切。")
# \\输出一个斜扛 \n换行  \t制表符
print("You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.")

pome = """
\tThe lovely world
with logic so firmly planted
cannot discern \n the needs of love
nor comprehend passion from intuition
and requires an explanation
\n\t\twhere there is none.
"""

print("------------------")
print(pome)
print("------------------")
# print(print(print(pome)))   # 多打印出2个None,怎么理解?可以这样用吗?


five = 10 - 2 + 3 - 6
print("这应该是five:%s" % five)


def secret_formula(started):
    jelly_beans = started * 500
    jars = jelly_beans / 1000
    crates = jars / 100
    return jelly_beans, jars, crates


start_point = 10000
# 函数调用的返回值赋值给变量,这个要学习记录(注意返回值的数量与变量的数量应该是相等的)
beans, jars, crates = secret_formula(start_point)

print("一个起点: %d" % start_point)
print("我们有%d个豆子,%d个罐子和%d个板条箱。" % (beans, jars, crates))

start_point = start_point // 10

print("我们也可以这样做:")
print("我们有%d个豆子,%d个罐子和%d个板条箱。" % secret_formula(start_point))

 

posted on 2018-07-10 22:33  你猜我猜你猜我猜不猜  阅读(95)  评论(0)    收藏  举报