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
fourstring
V2EX  ›  Python

Python3 的''' '''字符串如何保证在 IDE 里对齐,写到文件里又能不带空格?

  •  
  •   fourstring · 2016-02-05 16:44:54 +08:00 · 2883 次点击
    这是一个创建于 2974 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题。。。
    可能题目不太清除,我放张图就明白了

    IDE 是 pycharm ,由于强迫症,这样看起来真不舒服。。。

    9 条回复    2016-02-06 15:05:10 +08:00
    SErHo
        1
    SErHo  
       2016-02-05 17:19:18 +08:00 via iPad   ❤️ 2
    强迫症的话处理一下啰 https://docs.python.org/3/library/textwrap.html textwrap.dedent(text)
    hcwhan
        2
    hcwhan  
       2016-02-05 17:25:19 +08:00
    \n
    fourstring
        3
    fourstring  
    OP
       2016-02-05 18:05:53 +08:00
    @SErHo 感谢!
    pynix
        4
    pynix  
       2016-02-05 19:15:16 +08:00   ❤️ 1
    Ruby 自带光环
    RqPS6rhmP3Nyn3Tm
        5
    RqPS6rhmP3Nyn3Tm  
       2016-02-05 19:27:13 +08:00 via iPad
    Command option L
    glasslion
        6
    glasslion  
       2016-02-06 00:32:02 +08:00
    text= ("Line1\n"
    "Line2\n"
    "Line3\n")
    fourstring
        7
    fourstring  
    OP
       2016-02-06 12:38:25 +08:00
    @glasslion 不用带+么?
    glasslion
        8
    glasslion  
       2016-02-06 14:53:42 +08:00   ❤️ 1
    @fourstring 不用, Python 会自动拼接两个相邻的字符串
    fourstring
        9
    fourstring  
    OP
       2016-02-06 15:05:10 +08:00
    @glasslion 谢谢!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3077 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 14:35 · PVG 22:35 · LAX 07:35 · JFK 10:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.