下载地址 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. WebForm aspx页面传值---7种方式

    1.get方式 发送页 <form id="form1" runat="server">    <div>        <a h ...

  2. 3.Complementing a Strand of DNA

    Problem In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'. The r ...

  3. 课堂笔记-background属性

    一,background-position:(图片定位)   三种写法:   1):按%比,左上角最小(0%,0%),右下角最大(100%,%100):   2):(x,y)左上角最小(0,0),右下 ...

  4. java的三大框架(二)---Struts2

    Strtu2框架 1.控制器:ActionServlet充当控制层 2.模型层:由ActionForm及业务JavaBean实现 3.视图:用户的看到并与之交互的界面   由struts标签库和jsp ...

  5. 关于SQL Cookbook里dept与emp表结构以及数据

    用MYSQL 写了一下,将number变成int, to_date去掉即可. DROP TABLE IF EXISTS `dept`; CREATE TABLE `dept` ( `DEPTNO` ) ...

  6. Servlet 3.0 异步模式

    Servlet 3.0标准新增了异步处理的支持. 进行异步处理的Servlet和作用于该Servlet的拦截器都必须声明对于异步处理的支持.

  7. 使用pngquant命令近乎无损压缩PNG图片大小减少70%左右

    1.安装 wget http://pngquant.org/pngquant-2.8.2-src.tar.gz tar -xzf pngquant-2.8.2-src.tar.gz cd pngqua ...

  8. ubuntu 16.04 启用root用户方法

    引用:http://blog.csdn.net/sunxiaoju/article/details/51993091 1.使用:sudo passwd root设置root的密码,如下图所示: 2.使 ...

  9. python统计元素重复次数

    python统计元素重复次数 # !/usr/bin/python3.4 # -*- coding: utf-8 -*- from collections import Counter arr = [ ...

  10. [转载]Eclipse调试Java的10个技巧

    原文:http://www.oschina.net/question/82993_69439 我也特别喜欢的是Drop to frame. 在看这篇文章前,我推荐你看一下Eclipse 快捷键手册,我 ...