zoukankan      html  css  js  c++  java
  • 复习

    1、字符串与字节的转换:

    1 # byte to string
    2 msg = '我爱祖国'
    3 print(msg)
    4 print('--', msg.encode())  # 进行字节编码
    5 # 或者print(msg.encode(encoding='utf-8'))
    6 # python3.8系统默认编码是utf-8
    7 print('--', msg.encode().decode()) # 解码回到字符串 
    View Code

    2、for 循环

     1 for i in range(10):
     2     if i < 3:
     3         print('loop',i)
     4     else:
     5         continue
     6 #continue是用来跳出本次循环后继续下次循环;而break是用来结束整个循环
     7 #那么调试(debug),会发现i=3之后都没有打印hehe...
     8     print('hehe...')
     9 for i in range(0,10,2):
    10    print('输出0-9之间的偶数',i)

    3、登陆验证

     1 import getpass
     2 _username = 'Flagon'; _password = 'abc'
     3 username = input("请输入用户名:")
     4 password = input("请输入密码:")
     5 # password = getpass.getpass("请输入密码:")  # 这是不显示输入的密码
     6 print('username:', username)
     7 print('password:', password)
     8 
     9 if _username == username and _password == password:
    10     print('Welcome user {name} login'.format(name=username))
    11 else:
    12     print('Invalid username or password!')
    View Code
  • 相关阅读:
    Celery异步框架
    彻底理解cookie,session,token
    消息队列
    pip源、搭建虚拟环境、git
    全文检索
    redis高级
    redis基础
    基本数据结构和算法(python代码实现算法)
    MySQL数据库高级
    MySQL数据库进阶
  • 原文地址:https://www.cnblogs.com/gzj137070928/p/13716495.html
Copyright © 2011-2022 走看看