Python编程之路----day1

Python程序:
        1. 
            终端:
                D:\Program Files\Python\Python36\python.exe D:\Python\class1.py
            解释器:
                D:\Program Files\Python\Python36\python.exe 
                
        2. 文件形式
            #/usr/bin/u/ubv/a python
            
            python 1.py
            
            ./1.py      添加执行权限
            
        3. python编码格式          

#/usr/bin/u/ubv/a python
# -*- coding:utf-8 -*-


            补充:
                
            字节,位
            unicode   utf8   gbk
            utf8: 3
            gbk : 2
        
        4. python打印字符串

print("sdaadff")


        
        5. python输入

inp = input('>>>')
            
            PS:
                >>> hello
                inp = "hello"
                
                
                >>> 10
                inp = "10"
                
                # 如果将字符串转换成数字     new_inp = int(inp)
                
                inp * 10 =????? 


            
            
        6. 变量名
            变量名只能包含“字母、数字、下划线”
            
            要求:
                不能数字开头
                不能使用关键字
                建议不要用python内置的。。。。

        
        7. 条件语句
            1. 基本
            2. 嵌套
            3. if   elif   else ...
            
        8. while循环
          

 while 条件:
                ....
        
            print('...')
            
            补充:
                a. while else
                b. continue   break
                   continue  :  终止当前循环,开始下一次循环
                   break     :  终止所有循环


            
        用户登陆(三次机会重试)
        

count = 0
        while count < 3:
            user = input('>>>')
            pwd = input('>>>')
            if user == 'ocean' and pwd == 'password123':
                print('welcome login')
                print('crazy tank')
                break
            else:
                print('用户名或者密码错误')
            count = count + 1

猜你喜欢

转载自blog.csdn.net/sandy9919/article/details/81239298