python1day
下载地址 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的更多相关文章
- Python-1-Day
C = float(input("Enter a degree in Celsius:"))F = (9/5) * C + 32print("{0} Celsius is ...
随机推荐
- Oracle----Job
最近需要使用到Oracle的定时Job,感觉到学习能力很重要,同时也感觉到及时总结和记笔记也很重要,现在开始总结Job的使用
- 2016HUAS_ACM暑假集训4B - 递推
这种数学推理题目题意极其明显,在做的时候,可以多写几组,这样找起规律来会容易些.概括起来就是:题意简单暴力,案例毫无价值. 一个三角形最多可以把一个平面分成两部分,两个三角形最多是8(2+6)部分,而 ...
- 命名空间System.Threading命名空间的同步锁 Monitor类
官方备注: Monitor类通过向单个线程授予对象所来控制对对象的访问.对象所提供限制访问代码块的能力.当一个线程拥有对象的锁时,其他任何线程都不能获取该锁.还可以使用Monitor来确保不会允许其他 ...
- [转]使用Maven添加依赖项时(Add Dependency)时,没有提示项目可用,并且在Console中,输出: Unable to update index for central|http://repo1.maven.org/maven2 。
使用Maven添加依赖项时(Add Dependency)时,没有提示项目可用,并且在Console中,输出: Unable to update index for central|http://re ...
- Ubuntu学习——第一篇
一. Ubuntu简介 Ubuntu(乌班图)是一个基于Debian的以桌面应用为主的Linux操作系统,据说其名称来自非洲南部祖鲁语或科萨语的“ubuntu”一词,意思是“人性”.“我的存在是因为大 ...
- Python之路,day8-Python基础
***面向对象的好处*** 更容易扩展.提高代码使用效率,使你的代码组织性更强,更清晰 更适合复杂项目的开发 封装 把功能的实现细节封装起来,只暴露调用接口 继承 多态 接口继承 定义 类----&g ...
- ASP.NET Web 应用程序及页面生命周期
以客户端浏览器向 ASP.NET Web 应用程序页面发送请求(Request)为起点,以浏览器收到 Web 服务器的响应(Response)为终点,这一完整的过程被称为"应用程序及页面的生 ...
- C#防止反编译
http://blog.csdn.net/wangpei421/article/details/42393095 http://www.cnblogs.com/tianguook/archive/20 ...
- php中判断字符串是否全是中文或含有中文的实现代码
<?php header('Content-type:text/html; charset=utf-8'); $str = '你好'; if(preg_match('/^[\x{4e00}-\x ...
- RPC与hadoop
rlgdj的这样的话,真正的实现类在Server端,客户端调用方法的时候,只能得到得到从Server端的返回值.看来接口中的抽象方法必须要有返回值啊.ps.右下角的Client端的main()中rpc ...