3
字符串我有以下的模板,我正在寫一個config
文件:格式蟒蛇
template = """mkdir /root/.ssh \
&& chmod go-rwx /root/.ssh \
&& apt-get install -y \
gcc \
libssl-dev \
python-pip \
openssh-server \
PATH=/usr/local/jdk1.8.0/bin:$PATH
"""
with open('config', 'w') as f:
f.write(template)
,我發現了以下格式:
mkdir /root/.ssh && chmod go-rwx /root/.ssh && apt-get install -y gcc libssl- dev python-pip openssh-server
代替:
mkdir /root/.ssh \
&& chmod go-rwx /root/.ssh \
&& apt-get install -y \
gcc \
libssl-dev \
python-pip \
openssh-server \
PATH=/usr/local/jdk1.8.0/bin:$PATH
如何將我的字符串模板格式化爲正確的格式?