-1
創建文件在Linux上,我想它的名字與Python創建一個PID文件,我知道是bash可能是這樣的:與PPID
outfile=/tmp/saul.$$.tmp
,然後我可以只重定向輸出變量:
echo "Hello World" >> $outfile
我在python試過這樣:
log="/home/ss055g/log_$$.log"
f=open(log,'w')
f.write("Esto es una prueba")
f.close()
,並沒有工作。它創建的日誌是:log _ $$。log,我的問題是,如何將pid添加到日誌而不是$$。
在此先感謝