下载地址 https://www.python.org/downloads/

一 配置环境变量

右键计算机--属性--高级系统设置-高级-环境变量-系统变量--Administratorpath编辑-

添加

C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\Scripts\

C:\Users\Administrator\AppData\Local\Programs\Python\Python35-32\Scripts\

C:\Python27\

C:\Python27\Scripts

二 在windows打python 程序

创建一个文件 改成.py文件 编辑 print “hello word!”

cmd

进入d: 运行xx.py

三  在乌版图系统中vim 编辑一个文件

#!/usr/bin/python

#!/usr/bin/env python 系统默认最高级python 版本

print ("hello")

print ("cc\ndd")  \n 是换行符

四 命名的规则

变量定义的规则:

    • 变量名只能是 字母、数字或下划线的任意组合
    • 变量名的第一个字符不能是数字
    • 以下关键字不能声明为变量名
      ['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']

son_of_twins_gf

SonOfTwinaGf  只能2种选其一

五 python注释

当行注视:# 被注释内容

  多行注释:""" 注释内容 """

  

六 用户输入 

python 3    user_name = input("what your name")

python 2.7 user_name=raw_input("what your name")

python 2.7  input  申明变量

name = jack   #先赋予变量

user_name=input("what your name")

what your name        name # 显示出what  your name    输入 name

print (user_name) #  打印 user_name

jack

七 替换

name = input("what your name:")

age = input("how old you:")  #%d int(input("how old you")) #%f 代表浮点 例如3.000
work = input("what are you doning:")
mesage = '''
--------------------
Name : %s
AGE : %s
Work : %s
''' % (name,age,work)
print (mesage) 八 常用模块 ( getpass os tab)模块
乌版图python3 用
import getpass
name = input("what your name:")
password = getpass.getpass("password")
print(name,password)
在 python 环境下
import os
os.system("df -h") a=os.popen("df -h").read()
print(a)
#结果打印出来 os.mkdir("you Dir") 创建目录 os.system("ls z*") import tab
1 #!/usr/bin/env python
2 # python startup file
3 import sys
4 import readline
5 import rlcompleter
6 import atexit
7 import os
8 # tab completion
9 readline.parse_and_bind('tab: complete')
10 # history file
11 histfile = os.path.join(os.environ['HOME'], '.pythonhistory')
12 try:
13 readline.read_history_file(histfile)
14 except IOError:
15 pass
16 atexit.register(readline.write_history_file, histfile)
17 del os, histfile, readline, rlcompleter 九 if 语句 else

user = 'alex'
passwd= 'alex3714'

username = input("username:")
password = input("password:")

if user == username and passwd == password:
print("Welcome login")
else:
print("Invalid username or password..")

if user == username and passwd == password:
print("Welcome login")
else:
print("Invalid username or password..")

if else 优化

user = 'alex'
passwd= 'alex3714'

username = input("username:")
password = input("password:")

if user == username and passwd == password:
print("Welcome login")
else:
print("Invalid username or password..")

十 for i in range(10):

print (i)

缩进 TAB

往回缩 shift tab

age =31
con = 0
for i in range(10):
if con <3:
guss = int(input("how old:"))
if guss == age:
print("ok")
break
elif guss <age:
print("smale")
else:
print("big")
else:
wan = input("plase hai wan ma?")
if wan == 'y':
con = 0
contiue# 不往下走
else:
print("no")
break
con=con+1



python1day的更多相关文章

  1. Python-1-Day

    C = float(input("Enter a degree in Celsius:"))F = (9/5) * C + 32print("{0} Celsius is ...

随机推荐

  1. 关于redis扩展安装及使用

    11月23日,预留 http://blog.sina.com.cn/s/blog_68431a3b0102v6dz.html http://blog.csdn.net/rachel_luo/artic ...

  2. java播放背景音乐的几种方式

    大四第一学期快结束了,准备找实习单位的时候,用了一周的时间去投简历去面试,结果没有一家有反馈要不就是面试没通过,拿着iOS的项目(在老师工作室的外包项目)去面试java开发,结果全部碰壁. 第一种,直 ...

  3. UVA 1151

    /* 题意:有n个点,现在需要联通所有,有q种套餐可以选择, 当然套餐之外也可以自己添加边,意为达到最短距离. 题意很明显,不知道需要使用哪一种套餐, 那么需要枚举每一种套餐的情况. 然后再进行对比. ...

  4. HDU 5937 Equation

    题意: 有1~9数字各有a1, a2, -, a9个, 有无穷多的+和=. 问只用这些数字, 最多能组成多少个不同的等式x+y=z, 其中x,y,z∈[1,9]. 等式中只要有一个数字不一样 就是不一 ...

  5. JSBInding+Bridge.NET:把C#编译为Js

    编译步骤: 1. 用 VS 2015 打开 BridgeProj/BridgeProj.sln ,编译 2. 将生成 BridgeProj/Bridge/output/bridge.js,对应于 Br ...

  6. mac快捷键

    切换 1. 应用程序切换 command tab 2.应用程序中的窗口间切换 command ~ ===================== 通用 1. 隐藏窗口 command H 2. 最小化窗口 ...

  7. Perforce P4V,添加映射

  8. 3、SSH高级服务

    1.ssh服务生成新的公钥和私钥[root@rhel6_80 ~]# ssh-keygen Generating public/private rsa key pair. Enter file in ...

  9. C#调试器导航

    本快速入门演示如何在 Visual Studio 调试会话中导航,以及如何在会话中查看和更改程序状态. 本 快速入门适用于不熟悉用 Visual Studio 进行调试的开发人员,以及要详细了解在 V ...

  10. Eclipse debug高级技巧(转)

    Debug视图 认识debug视图,红色部分框为线程堆栈视图,黄色部分框为表达式.断点.变量视图,蓝色部分为代码视图. 线程堆栈视图 分别介绍一下这几个按钮的含义: 1.表示当前实现继续运行直到下一个 ...