• 【Python】各种转义字符\\\\\\


    今日阅读:【17个新手常见Python运行时错误】http://www.dedecms.com/knowledge/program/other/2012/0731/4046.html

    今日学习:

    1. \n 输出的是换行

    2.输出string时要注意引号的

    3.如果要用%r,%s输出string,不用用逗号隔开。

    eg: days=‘Monday Tuesday Wedesday Thuseday Friday Saturday Sunday’

          print"Here are the days:%r" %days

    4.如果输出string有用到换行\n关键字,用%s输出有换行效果,但如果用%r,则是直接输出\n字符,无换行效果。

    5.输出的“”“。。”“” 三引号的用法要注意一下。用三引号输出的话,就是里面的string语句可以有很多句。可以自定格式。

    6.【\的使用】输出的string中如果有会引起系统误会的字符,则在此符号前使用\,那么它就会按原样输出了。(这个在C里好像叫转义符号)

    7.【Escape Sequences】

    This is the list of all of the escape sequences Python supports. You may not use many of these, but memorize their format and what they do anyway. Also try them out in some strings to see if you can make them work.

    EscapeWhat it does.
    \\ Backslash ()
    \' Single quote (')
    \" Double quote (")
    \a ASCII Bell (BEL)
    \b ASCII Backspace (BS)
    \f ASCII Formfeed (FF)
    \n ASCII Linefeed (LF)
    \N{name} Character named name in the Unicode database (Unicode only)
    \r ASCII Carriage Return (CR)
    \t ASCII Horizontal Tab (TAB)
    \uxxxx Character with 16-bit hex value xxxx (Unicode only)
    \Uxxxxxxxx Character with 32-bit hex value xxxxxxxx (Unicode only)
    \v ASCII Vertical Tab (VT)
    \ooo Character with octal value ooo
    \xhh Character with hex value hh

    --------------------------------------------------------------------------------------------------------------------------------------------------------------

    【Most programming errors in the beginning (and even later) are simple spelling mistakes, typos, or getting simple things out of order.】

    【Periodically go through your notes and see if you can figure these things out after you've completed more exercises. Sometimes though you may need to go back a few exercises and go through them again.】

    【Always remember this: %r is for debugging, %s is for displaying.】

    感谢阅读,一起努力呗!
  • 相关阅读:
    oc获得设备类型
    oc代码规范
    图片下载进度
    Nsdate的各种常用操作
    学习视频
    ios 编码转换 保存文件
    免费代码托管网站
    两年JAVA程序员的面试总结
    Java 性能优化的 45 个细节
    7年Java游戏后端,被淘汰辛酸史
  • 原文地址:https://www.cnblogs.com/jennyhui/p/2750254.html
Copyright © 2020-2023  润新知