Python 语法,这是哪条规则允许这样做的? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 2020-05-14 21:09:41 +08:00 4935 次点击
    这是一个创建于 2054 天前的主题,其中的信息可能已经有所发展或是发生改变。

    图片

    我试了一下,是有效的.

    第 1 条附言    2020-05-15 00:01:22 +08:00
    a_dct = { 'key': 'value to looooooooooooooooooooong' 'looooooooooooooooooooooooooooooong', 'another_key':'no error happened' } 

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

    第 2 条附言    2020-05-15 00:05:39 +08:00
    没见过世面的样子.

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

    https://sm.ms/
    Cuo
        11
    Cuo  
       2020-05-14 21:49:03 +08:00   1
    为了看不到图的 V 友

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

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

    google 搜 python string too long 就行了
    imn1
        15
    imn1  
       2020-05-15 01:32:36 +08:00
    我经常这样写
    还可以字节类型
    b'……'
    '……'
    '……'
    '……',

    场合:一个 base64 编码的文件……
    imn1
        16
    imn1  
       2020-05-15 01:36:15 +08:00
    呃,上面写错了,每行前面都要 b 开头,不然会报错
    laike9m
        17
    laike9m  
       2020-05-15 02:32:16 +08:00   2
    一般建议这么写

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

    加上括号
    zhidian
        18
    zhidian  
       2020-05-15 02:48:24 +08:00
    C 语言来的。
    zhidian
        19
    zhidian  
       2020-05-15 02:50:19 +08:00   1
    ysc3839
        20
    ysc3839  
       2020-05-15 08:52:15 +08:00 via Android
    大概是继承自 C 语言的规则。
    no1xsyzy
        21
    no1xsyzy  
       2020-05-15 09:46:36 +08:00   1
    这个甚至可以混杂 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
        22
    bwangel  
       2020-05-15 10:09:39 +08:00   1
    https://docs.python-guide.org/writing/style/#line-continuations

    Python Guide 这个文档真的挺好的,值得一读。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5809 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 02:07 PVG 10:07 LAX 18:07 JFK 21:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86