美文网首页
笨方法学Python-习题9-打印,打印,打印

笨方法学Python-习题9-打印,打印,打印

作者: Python探索之路 | 来源:发表于2020-01-15 09:16 被阅读0次

    将打印进行到底。

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    
    # Here's some new strange stuff, remember type it exactly
    
    days = "Mon Tue Wed Thu Fri Sat Sun"
    months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
    
    print("Here are the days: ", days)
    print("Here are the months: ", months)
    
    print("""
    There's something going on here.
    With the three double-quotes.
    We'll be able to type as much as we like.
    Even 4 lines if we want, or 5, or 6.
    """)
    

    运行结果:

    ex9_运行结果

    观察运行结果,不难发现"""可以实现多行的打印,不需要每行都使用一次print函数。
    “\n”具有换行的作用。

    小结

    1. “\n”实现换行。
    2. 对于多行组成的长字符串,可以使用用"""来进行打印,注意中间没有引号之间没有空格。

    相关文章

      网友评论

          本文标题:笨方法学Python-习题9-打印,打印,打印

          本文链接:https://www.haomeiwen.com/subject/ixyzactx.html