下载地址 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. html+css基础知识总结

    1.HTML书写的基本规范      img标签必须得写alt=""      标签名和属性名字必须小写      引号必须用双引号      双标签必须有闭合标签      单标 ...

  2. ThinkPHP BASE

      对于thinkphp 开源框架来说  是一个基于  模型/控制器/视图 的结构 V(View):视图接收来自用户操作的信息返回到 对应的控制器或方法 C (controller):控制器则调用 相 ...

  3. android WeakReference(弱引用 防止内存泄漏)与SoftReference(软引用 实现缓存机制(cache))

    在Android开发中,基本上很少有用到软引用或弱引用,这两个东东若用的很好,对自己开发的代码质量的提高有很大的帮助.若用的不好,会坑了自己.所以,在还没有真正的去了解它们之前,还是慎用比较好. 下面 ...

  4. HDU1434(终于用优先队列a了一题。。。了解度+1)

    #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #inclu ...

  5. 简谈ashx

    是一般处理程序, 是asp.net web 组件的一种,ashx是其扩展名. 实现IHttpHandler接口,接收并处理http请求.这个接口有一个IsReusable成员,一个待实现的方法Proc ...

  6. 详解wait和waitpid函数

    #include <sys/types.h> /* 提供类型pid_t的定义 */ #include <sys/wait.h> pid_t wait(int *status) ...

  7. tomcat building

    https://tomcat.apache.org/tomcat-7.0-doc/building.html https://tomcat.apache.org/tomcat-7.0-doc/BUIL ...

  8. c# List去重

    1 list如果数据是值类型,比如list<int> 这种,添加linq之后就可以使用list = list.Distinct().ToList(); 2 如果是数据是引用类型,比如中间是 ...

  9. 10天学会phpWeChat——第七天:创建一个自适应PC网站+H5移动端的模块

    本教程基于phpWeChat核心框架1.1.0+版本.下载地址:http://s.phpwechat.com/app_38026ed22fc1a91d92b5d2ef93540f20 通过前面六讲的系 ...

  10. 自动运维:Ansible -ansible tower

    文档主页:http://docs.ansible.com/参考文档:http://docs.ansible.com/ansible/参考文档:http://docs.ansible.com/ansib ...