python几个简单的入门程序

#分片示例
#对http://www.something.com形式的URL进行分割
url=input("Please enter a URL: ")
domain=url[11:-4]
print("Domain name:"+domain)



#日期转换
months=["January","February","March","April","May","June","July","August","September","November","December"]
endings=["st","th","rd"]+17*["th"]\
        +["st","th","rd"]+7*["th"]\
        +["st"]
year=input("Year:");
month=input("Month (1-12):")
day=input("Day (1-31):")
month_number=int(month)
day_number=int(day)
month_name=months[month_number-1]
ordinal=day+endings[day_number-1]
print(month_name+' '+ordinal+','+year)



#序列成员资格
datebase=[
    ["albert","1234"],
    ["dilbert","4242"],
    ["smith","7524"],
    ["jones","9843"]
    ]
username=input("User name: ")
pin=input("PIN code: ")
if [username,pin] in datebase: print("Access Granted")
else: print("No Granted")


你可能感兴趣的:(------【模板】)