miniyao
V2EX  ›  问与答

为什么转义符\n 提交到服务器上后,就变成了\r\n 换行符?

  •  
  •   miniyao · May 14, 2018 · 2743 views
    This topic created in 3109 days ago, the information mentioned may be changed or developed.

    印象中 Unix OS X Linux 不是默认换行符都统一只用 \n 了吗?(Windows 才用 \r\n 的吧)

    把:

    'item\nA'
    

    在表单提交之后,服务器收到的是:

    ‘ item\r\nA'
    

    语言是 py3,前后端都是 ubuntu。

    5 replies  •  2018-05-14 12:39:36 +08:00
    hundan
    hundan
    May 14, 2018 via Android
    1
    印象中 mac 用\r
    coderfox
    coderfox
    May 14, 2018 via Android
    2
    印象中 HTTP 协议规定换行符是 CRLF。
    Arnie97
    Arnie97
    May 14, 2018 via Android
    3
    @hundan 你说的那是 PowerPC 时代的老 Mac
    msg7086
    msg7086
    May 14, 2018
    4
    Windows 上的\n 可能就是两个字符。
    picture2200
    picture2200
    May 14, 2018 via Android
    5
    网页是不是在 Windows PC 访问的?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4595 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 06:13 · PVG 14:13 · LAX 22:13 · JFK 01:13
    ♥ Do have faith in what you're doing.