python print 输出赋值到变量

In [52]: import io
In [53]: row = ('ACME', 50, 91.5)
In [54]: ','.join(row)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-54-b1add756d97c> in <module>
----> 1 ','.join(row)

TypeError: sequence item 1: expected str instance, int found
In [55]: r = io.StringIO()
In [56]: print(*row,sep=',',file=r)
In [57]: r.getvalue()
Out[57]: 'ACME,50,91.5\n'
In [58]: row = r.getvalue()
In [59]: row
Out[59]: 'ACME,50,91.5\n'

 

上一篇:Linux性能优化-软中断


下一篇:Cert manager自动签发/更新证书