while
==============
for
for i in range(1,6):
print (i)
2019年12月23日 星期一
選擇結構
score=int(input("請輸入的分數"))
if (score>90):
print("good")
elif score>70:
print("pretty good")
else:
print("work hard")
if (score>90):
print("good")
elif score>70:
print("pretty good")
else:
print("work hard")
===========加入 判斷 100以上 ,是否在重新執行
yon=True
while yon:
score=int(input("請輸入的分數"))
if (score>100):
print("你要吃藥了")
elif (score>90 ):
print("good")
elif (score>70 ):
print("pretty good")
else:
print("work hard")
yon=input("按y是繼續 or 按n是停止 ")
if yon=="y":
yon=True
if yon=="n":
yon=False
2019年12月4日 星期三
python about 目錄 檔案
import os
os.environ.get('PATH')
===========
import os
os.path.expanduser("~") #取得使用者 家目錄路徑
==========
import os
home=os.path.expanduser("~") #取得使用者 家目錄路徑
picpath=os.path.join(home,"picture","test","test.jpg")
print(picpath)
os.environ.get('PATH')
===========
import os
os.path.expanduser("~") #取得使用者 家目錄路徑
==========
import os
home=os.path.expanduser("~") #取得使用者 家目錄路徑
picpath=os.path.join(home,"picture","test","test.jpg")
print(picpath)
訂閱:
文章 (Atom)