第一天开始进行学习python

 

1、讲述了python的发展过程

      python 2系列已经过去,走入划时代的python 3

      而很多也是模块都是在3的基础上进行更新,2代已停止更新插件。

      当然也有一个插件异步的是在2的基础上的,不过也完了 70%像 3进化。

 

2、第一天讲了关于学习各种有趣的打印
           "hello world"

           #!/usr/bin/env python

           print("hello world")

        3代的玩法不太一样了,多了括号起来。

3、讲述了字符的转变

       utf-8  、unicode

4、用户的交互程序

      input("输入")

5、关于if .. else 

     进行判断   if .. elif .. else .. 

      写了一个判断用户的的账号和密码的

       #!/usr/bin/env python

       #-*- codiing:utf-8 -*-

       import getpass

       _username = 'alx'

       _password = 'abc123'

       username = input("username:")

        password = getpass.getpass("password:")  #进行输入加密处理

       if  _username == username  and _password == password:

                 print("登录成功!")

        else:

                  print("账号或密码错误")

6、 关于while循环

#-*- coding:utf-8 -*-
__author__ = 'andylin'
__date__ = '2017/6/23 13:52'

import getpass

_username = "alx"
_password = 'abc123'

while True:
username = input("username:")
password = getpass.getpass("password:")
if _username == username and _password == password:
print("登录成功!")
break
else:
print("账号或密码错误!请重新输入")

 

七、关于for

        输入多少次后就会进行lock
        

#-*- coding:utf-8 -*-
__author__ = 'andylin'
__date__ = '2017/6/23 13:52'

import getpass
import os
_username = "alx"
_password = 'abc123'

if os.path.isdir("lock"):
print("用户已经被锁了!")

for i in range(3):
username = input("username:")
password = getpass.getpass("password:")
if _username == username and _password == password:
print("登录成功!")
break
else:
print("账号或密码错误!请重新输入")
else:
os.mkdir("lock")

八、关于实现的
#-*- coding:utf-8 -*-
__author__ = 'andylin'
__date__ = '2017/6/23 13:52'


"""
多级菜单
1) 可依次选择进入各项子菜单
2)所需新知识点:列表、字典
"""

while True:
print """
请选省份:
1、广东 2、湖南
"""
try:
num = int(input("请输入数字:"))
except:
num = 0
if num == 1:
pass
elif num == 2:
while True:
print """
请输入市级:
1、长沙 2、返回
"""
try:
shi = int(input("请输入数字:"))
except:
shi = 0
if shi == 1:
pass
elif shi == 2:
break
else:
print("输入有误,请重新输入!")
else:
print("输入有误,请重新输入!")

初步的想法,因为根据课的内容是还没有学到函数那些的调用,所以,简单的实现方法!

      今天暂时学习的情况,革命尚未成功,还需继续努力!

posted @ 2017-06-27 21:08  黑夜与阳光  阅读(166)  评论(0编辑  收藏  举报