windows上的python能否在unix上使用_怎么用python在Windows系统下,生成UNIX格式文件
在Windows下?lián)Q行時,有兩個字符:回車(/r)和換行(/n)。但在Linux下,只有一個換行(/n)可使用unix2dos和dos2unix命令進(jìn)行格式的轉(zhuǎn)換:
參數(shù):
-k 保持輸出文件和輸入文件的日期時間戳不變
-o file 默認(rèn)模式 . 將file轉(zhuǎn)換,并輸出到file
-n infile outfile 新模式. 轉(zhuǎn)換infile, 并輸出到outfile
1. unix2dos
假設(shè)用vi新建一文本文件,輸入123456
[root@centos test]# ls -l a.txt
-rw-r--r-- 1 root root 7 Jan 7 21:31 a.txt
[root@centos test]# hexdump -c a.txt
0000000 1 2 3 4 5 6 /n
0000007
[root@centos test]# unix2dos -n a.txt b.txt
unix2dos: converting file a.txt to file b.txt in DOS format ...
[root@centos test]# ls -l
total 8
-rw-r--r-- 1 root root 7 Jan 7 21:31 a.txt
-rw------- 1 root root 8 Jan 7 21:34 b.txt
[root@centos test]# hexdump -c a.txt
0000000 1 2 3 4 5 6 /n
0000007
[root@centos test]# hexdump -c b.txt
0000000 1 2 3 4 5 6 /r /n
0000008
b.txt是轉(zhuǎn)換后的DOS下的文件
取消
評論
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的windows上的python能否在unix上使用_怎么用python在Windows系统下,生成UNIX格式文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 苹果新专利引发猜想:Vision Pro
- 下一篇: python如何读取csv文件列表页_每