推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
chaleaoch
V2EX  ›  Python

Python 语法,这是哪条规则允许这样做的?

  •  
  •   chaleaoch · May 14, 2020 · 5679 views
    This topic created in 2376 days ago, the information mentioned may be changed or developed.

    图片

    我试了一下,是有效的.

    Supplement 1  ·  May 15, 2020
    a_dct = {
        'key': 'value to looooooooooooooooooooong'
                'looooooooooooooooooooooooooooooong',
        'another_key':'no error happened'
    }
    
    

    大概是这个意思. 另外 有道做图床 是我在B站看到一个up主这么做的. 哎 没想到娃...原来不行.

    Supplement 2  ·  May 15, 2020
    没见过世面的样子.

    另外这个帖子对于楼主来说最大的收获是, https://sm.ms/ 呵呵呵,,,,
    22 replies  •  2020-05-15 10:09:39 +08:00
    ClericPy
    ClericPy
    May 14, 2020❤️1
    1
    {
    "canTryAgain": false,
    "scope": "SECURITY",
    "error": "207",
    "message": "Message[AUTHENTICATION_FAILURE]: User token must be authenticated.",
    "objectUser": null
    }
    lithbitren
    lithbitren
    May 14, 2020❤️2
    2
    看不到图,为啥我在 v2 经常看不到图。。
    wellsc
    wellsc
    May 14, 2020❤️1
    3
    虽然不知道你在说什么,但是觉得好厉害的样子
    wjm2038
    wjm2038
    May 14, 2020 via Android❤️1
    4
    图没了
    cherbim
    cherbim
    May 14, 2020❤️1
    5
    换个图床
    Cusmate
    Cusmate
    May 14, 2020❤️1
    6
    图片不显示了,AUTHENTICATION_FAILURE
    Trim21
    Trim21
    May 14, 2020
    8
    不行
    Cuo
    Cuo
    May 14, 2020
    9
    楼主感到疑惑的地方是字符串可以分成两行来写吗?
    hakono
    hakono
    May 14, 2020❤️1
    10
    实在看不下去了,LZ 找个图床吧,别想着用有道的图片链接了,有道不做登陆检测不得被你们撸成图床

    https://sm.ms/
    Cuo
    Cuo
    May 14, 2020❤️1
    11
    为了看不到图的 V 友

    ```python
    HOGE = {
    'FOO': r'^([0-9]|[1-9]\d|'
    r'[1-5]\d{4}|6[0-4]',
    'HEGO': 'string'
    }
    ```
    图上的内容大致是这么个意思
    ila
    ila
    May 14, 2020 via Android
    12
    盲猜 value 变成了 tuple
    lithbitren
    lithbitren
    May 14, 2020❤️1
    13
    盲猜字符串不用加号也能拼接,而且换行空格缩进不影响拼接
    ClericPy
    ClericPy
    May 14, 2020❤️1
    14
    字符串本来就可以不用加号拼接

    string - Wrap long lines in Python - Stack Overflow - https://stackoverflow.com/questions/3346230/wrap-long-lines-in-python

    google 搜 python string too long 就行了
    imn1
    imn1
    May 15, 2020
    15
    我经常这样写
    还可以字节类型
    b'……'
    '……'
    '……'
    '……',

    场合:一个 base64 编码的文件……
    imn1
    imn1
    May 15, 2020
    16
    呃,上面写错了,每行前面都要 b 开头,不然会报错
    laike9m
    laike9m
    May 15, 2020❤️2
    17
    一般建议这么写

    a_dct = {
    'key': ('value to looooooooooooooooooooong'
    'looooooooooooooooooooooooooooooong'),
    'another_key':'no error happened'
    }

    加上括号
    zhidian
    zhidian
    May 15, 2020
    18
    C 语言来的。
    ysc3839
    ysc3839
    May 15, 2020 via Android
    20
    大概是继承自 C 语言的规则。
    no1xsyzy
    no1xsyzy
    May 15, 2020❤️1
    21
    这个甚至可以混杂 f-string r-string 甚至 three quote string
    print("normal string\n"
    r"r-string, but \n is just \n" ", for LF use another normal string at end\n"
    f"f-string, {2+3=}\n"
    f"""three-quote f-string{ " ".join(str(i) for i in range(10)) }""")
    bwangel
    bwangel
    May 15, 2020❤️1
    22
    https://docs.python-guide.org/writing/style/#line-continuations

    Python Guide 这个文档真的挺好的,值得一读。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   866 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 21:23 · PVG 05:23 · LAX 13:23 · JFK 16:23
    ♥ Do have faith in what you're doing.