下载地址 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. javascript学习笔记全记录

          js的初步了解     1.就是用来修改样式的,修改的是行内样式.任何样式都能够修改.     2.css里面怎么写js就怎么写.     3.任何元素都能加事件:事件都要小写 js的三大 ...

  2. [非原创]eclipse中一些常见svn图标的含义

    项目视图   The Package Explorer view - 已忽略版本控制的文件.可以通过Window → Preferences → Team → Ignored Resources.来忽 ...

  3. Spring 的 NamedParameterJdbcTemplate(转)

    NamedParameterJdbcTemplate类是基于JdbcTemplate类,并对它进行了封装从而支持命名参数特性. NamedParameterJdbcTemplate主要提供以下三类方法 ...

  4. php中关于Map热点的运用

    给图像使用map标签,可以给图像的某个部分建立超连接 一般情况下用在图片上,如:<img src="Images/banner.gif" width="780&qu ...

  5. php 上传大文件配置upload_max_filesize和post_max_size选项

    php 上传大文件配置upload_max_filesize和post_max_size选项 (2014-04-29 14:42:11) 转载▼ 标签: php.ini upload _files[f ...

  6. Eclipse动态web工程(Dynamic Web Project)添加jar文件的正确方法

    Eclipse中,创建了动态web工程之后,如果需要添加新的jar文件,有两种方法.第一种是配置工程的“build path”,第二种则是将jar文件放在工程目录下的“/WebContent/WEB- ...

  7. 【P1915】[usaco09 dec gold]电视游戏问题

    在百度上搜到了nzx学长的题解orz 原题: 农夫约翰的奶牛们游戏成瘾!本来FJ是想要按照陶叫兽的做法拿她们去电击戒瘾的,可是后来他发现奶牛们玩游戏之后比原先产更多的奶.很明显,这是因为满足的牛会产更 ...

  8. squid源码安装下的conf文件默认值和提示

    #    WELCOME TO SQUID 3.0.STABLE26#    ----------------------------##    This is the default Squid c ...

  9. Live2D WebGL实现

    demo预览:http://www.kakinuma.date/l2d.html 官方:http://www.live2d.com/en/ sdk下载:https://link.zhihu.com/? ...

  10. 【IOS学习】1.IOS框架

    1.框架概述 iOS的系统架构分为四个层次:核心操作系统层(Core OS layer).核心服务层(Core Services layer).媒体层(Media layer)和可触摸层(Cocoa ...