標籤:password welcome correct python import
所學模組:
import os
import sys
import getpass
os.system("df -h")
cmd_res = os.system("df -h")
print(cmd_res) 為0,因為結果為0,如果想看結果,請使用如下寫法:
cmd_res = os.popen("df -h").read()
os.mkdir("directory")建立目錄
print(sys.path)
查看python匯入模組的路徑
一般/usr/lib/python2.7/site-packages
可以import模組,import模組時,不加尾碼py
if else用法
user = jack
passwd = 123456
username = input("username:")
password = input("password:")
if user == username:
print("username is correct.")
if passwd == password:
print("welcome log in.")
else:
print("password is invailid.")
最佳化:
user = jack
passwd = 123456
username = input("username:")
password = input("password:")
if user == username and passwd == password:
print("welcome login.")
else:
print("username or password is invailid.")
guess age:
age = 22
guess_num = int(input("guess your number"))
if guess_num = age:
print("configratulations,you got it")
elif guess_num > age:
print("thins smaller")
else:
print("think bigger")
Python學習記錄-2016-11-28