Python Note

charles 29天前 37

-*- coding: utf-8 -*-

from __future__ import print_function


print('python version %.2f' %(3.6) , end='' )


stock='tsmc'

price=220.5

print(' the %s price is %d' %(stock,price)  )

print(stock, price, sep=' = ')


print('%s: %-.4f, %05d' % ('RESULT', 3.14159, 42))


print('%s: %-.3f' % ('RESULT',3.14159), file=open('FILE','w'), end='' ) 

print( open('FILE','r').read() , ' 100%(from file) ' )   


print('\\n*2= \n\n', end='')



import os

print(__name__)

print(                                                      __file__)

print(                           os.path.abspath(__file__))

print(os.path.dirname(os.path.abspath(__file__)))


---------------------------------------------- Results ----------------------------------------------------------------

python version 3.60 the tsmc price is 220

tsmc = 220.5

RESULT: 3.1416, 00042

RESULT: 3.142  100%(from file) 

\n*2= 



__main__

test.py

/twhome/cmliut/p/test.py

/twhome/cmliut/p


最新回復 (0)
全部樓主
返回