tr ' ' ',' <input >output
Substitutes each space with a comma, if you need you can make a pass with the -s flag (squeeze repeats), that replaces each input sequence of a repeated character that is listed in SET1 (the blank space) with a single occurrence of that character.
Use of squeeze repeats used to after substitute tabs:
tr -s '' <input | tr '' ',' >output
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…