首页 > 代码库 > 得做好笔记了

得做好笔记了

"""
name = raw_input("Username")
pwd = raw_input("PassWord")
if name == "alex"and pwd == "123":
    print(‘yes‘)
else:
    print(‘no‘)
"""

inp = raw_input(">>>")
if inp == "1":
    print(111)
elif inp == "2":
    print(222)
elif inp =="3":
    print(333)
else:
    print(...)
    
    
    
if name == "alex" or name == "eric":
    只要满足任何一个or的条件,进入当前代码块
    
1.
if 条件:
    代码块
else:
    代码块
2.
peif 条件:    
    代码块
else:
    代码块
else:
    代码块


3/条件:
   True        False
   1 > 2 n1 > n2   n1 == n2
   name == "alex" or name == "eric"
   name != "alex"
   name == "alex" and pwd == "123"
   
"""
import time

n1 = True

while n1:
    print(‘1‘)
    time.sleep(1)
    n1 = False

print(‘end‘)
"""


"""
import time
kaishi = 1
flag = True
while flag:
    print(kaishi)
    if kaishi == 10:
        flag = False
    kaishi = kaishi + 1
    time.sleep(1)
print(‘end‘)
    



kaishi = 1
while True:
    print(kaishi)
    if kaishi == 10:
        break
    kaishi = kaishi + 1

#使用while循环输入1-10除7以外(break用于跳出所有循环,并且breake后面的代码不再执行
continue用于跳出本次循环,继续下次循环)"""
start = 1
while True:
    if start == 7:
        start += 1
        continue
    print(start)
    if start == 10:
        break
    start += 1
    
# _*_ coding:utf-8 _*_

temp = "张强"# utf-8 
#解码,需要指定原来是什么编码
temp_unicode = temp.decode(utf-8)
#编码,需要指定要编成什么编码
temp_gbk = temp_unicode.encode("gbk")

print(temp_gbk) 


算数
    + - * / %(取余) //(整除)
    py2: 9/2=4
      9/2=4.5(导入模块)
    py3: 9/2=4.5

PYCHARM
        1、模板
            file=>settings=>Editor=>file and code templete=> python script=>
            # usr/bin/env python
            # _*_ coding:utf-8 _
                from __future__ import division
                val = 9/2
                print (val)
        2、文字大小
            file => settings=>editor=>color and front=>save as..=>zitidaxiao
        3、运行
            a.点击要运行的文件,右键run
            b.
                view=>toolbar
                选中要执行的文件
                点击运行
            c.在当前文件空白处,右键,run
        4.切换py版本
            file=>settings=>

 

得做好笔记了