arlenmbx@arlenmbx-ThinkPad-X130e:~$ su root
密码:
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx# python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> dic={'f1':1,'f2':2,'f3':3}
>>> dic
{'f1': 1, 'f2': 2, 'f3': 3}
>>> for key in dic:
... print dic[key]
...
1
2
3
>>> print dic.keys()
['f1', 'f2', 'f3']
>>> print dic.values()
[1, 2, 3]
>>> print dic.items()
[('f1', 1), ('f2', 2), ('f3', 3)]
>>> dic.clear()
>>> print dic
{}
>>> type(dic)
<type 'dict'>
>>> f=open("a.py","r+")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'a.py'
>>> f=open("a.txt","r+")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'a.txt'
>>> f=open("/home/arlenmbx/桌面/pro.txt","r+")
>>> f.write("hello world")
>>> f.close()
>>> chmod 755 python
File "<stdin>", line 1
chmod 755 python
^
SyntaxError: invalid syntax
>>> exit()
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx# chmod 755 b.py
chmod: 无法访问"b.py": 没有那个文件或目录
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx# cd /home/arlenmbx/桌面
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# dir
a.py a.py~ b.py b.py~ pro.txt
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# chmod 755 b.py
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# ./b.py
hha
hha
hha
hha
hha
hha
hha
hha
hha
hha
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# import b as bb
程序 'import' 已包含在下列软件包中:
* imagemagick
* graphicsmagick-imagemagick-compat
请尝试:apt-get install <选定的软件包>
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# python
Python 2.7.10 (default, Oct 14 2015, 16:09:02)
[GCC 5.2.1 20151010] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> def f(a,b,c):
... print a
... print b
... print c
...
>>> f(1,2,3)
1
2
3
>>> f(a=3,b=2,c=1)
3
2
1
>>> print(c=1,b=3,a=2)
File "<stdin>", line 1
print(c=1,b=3,a=2)
^
SyntaxError: invalid syntax
>>> f(c=1,b=3,a=2)
2
3
1
>>> def fun(*p):
... type(p)
... print p
...
>>> fun(1,2,3)
(1, 2, 3)
>>> def fun(*p):
... print type(p)
... print p
... fun(1,2,3,4)
File "<stdin>", line 4
fun(1,2,3,4)
^
SyntaxError: invalid syntax
>>> fun(1,2,3,4)
(1, 2, 3, 4)
>>> fun(1,2,4,3,4,5)
(1, 2, 4, 3, 4, 5)
>>> def fun1(**p):
... print type(p)
... print p
...
>>> fun1(1,2,)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: fun1() takes exactly 0 arguments (2 given)
>>> fun1(1,2,3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: fun1() takes exactly 0 arguments (3 given)
>>> fun1(a=1,b=2)
<type 'dict'>
{'a': 1, 'b': 2}
>>>
>>> def fun2(a,b,c):
... print a
... print b
... print c
...
>>> t=(3,4,5)
>>> fun2(*t)
3
4
5
>>>

python 模块包裹的更多相关文章

  1. 使用C/C++写Python模块

    最近看开源项目时学习了一下用C/C++写python模块,顺便把学习进行一下总结,废话少说直接开始: 环境:windows.python2.78.VS2010或MingW 1 创建VC工程 (1) 打 ...

  2. Python模块之configpraser

    Python模块之configpraser   一. configpraser简介 用于处理特定格式的文件,其本质还是利用open来操作文件. 配置文件的格式: 使用"[]"内包含 ...

  3. Python模块之"prettytable"

    Python模块之"prettytable" 摘要: Python通过prettytable模块可以将输出内容如表格方式整齐的输出.(对于用Python操作数据库会经常用到) 1. ...

  4. python 学习第五天,python模块

    一,Python的模块导入 1,在写python的模块导入之前,先来讲一些Python中的概念性的问题 (1)模块:用来从逻辑上组织Python代码(变量,函数,类,逻辑:实现一个功能),本质是.py ...

  5. windows下安装python模块

    如何在windows下安装python模块 1. 官网下载安装包,比如(pip : https://pypi.python.org/pypi/pip#downloads) pip-9.0.1.tar. ...

  6. 安装第三方Python模块,增加InfoPi的健壮性

    这3个第三方Python模块是可选的,不安装的话InfoPi也可以运行. 但是如果安装了,会增加InfoPi的健壮性. 目录 1.cchardet    自动检测文本编码 2.lxml    用于解析 ...

  7. Python基础篇【第5篇】: Python模块基础(一)

    模块 简介 在计算机程序的开发过程中,随着程序代码越写越多,在一个文件里代码就会越来越长,越来越不容易维护. 为了编写可维护的代码,我们把很多函数分组,分别放到不同的文件里,这样,每个文件包含的代码就 ...

  8. python 模块加载

    python 模块加载 本文主要介绍python模块加载的过程. module的组成 所有的module都是由对象和对象之间的关系组成. type和object python中所有的东西都是对象,分为 ...

  9. pycharm安装python模块

    这个工具真的好好,真的很喜欢,它很方便,很漂亮,各种好 pycharm安装python模块:file-setting-搜索project inte OK

随机推荐

  1. [LeetCode] Intersection of Two Linked Lists 求两个链表的交点

    Write a program to find the node at which the intersection of two singly linked lists begins. For ex ...

  2. [LeetCode] Jump Game II 跳跃游戏之二

    Given an array of non-negative integers, you are initially positioned at the first index of the arra ...

  3. python获取父类的子类(遍历,递归),并循环执行所有子类的某一方法

    前言 换了新工作,踏足于python语言的开发,也把自己的学习过程记录下来. 一,递归获取某一父类的所有子类 all_subclasses = {'0': '0'} def get_all_class ...

  4. 【WPF】整个自定义按钮后台添加

  5. Socket通信类

    package com.imooc; import java.io.BufferedReader; import java.io.IOException; import java.io.InputSt ...

  6. http

    HTTP是一个属于应用层的面向对象的协议,由于其简单.快速的方式,适用于分布式超媒体信息系统, 特点: 1.支持客户/服务器模式. 2.简单快速:客户向服务器请求服务时,只需传送请求方法和路径.请求方 ...

  7. MVC项目中,如何访问Views目录下的静态文件!

    <!--注意,是system.webServer节点,而非system.web--><system.webServer> <handlers> <add na ...

  8. python 抽象类、抽象方法、接口、依赖注入、SOLIP

    1.程序设计原则:SOLIP SOLIP设计原则 1.单一责任原则(SRP) 一个对象对只应该为一个元素负责 2.开放封闭原则(OCP) 对扩展开放,修改封闭 3.里氏替换原则(LSP) 可以使用任何 ...

  9. 【BZOJ 4580】【Usaco2016 Open】248

    http://www.lydsy.com/JudgeOnline/problem.php?id=4580 区间dp,f(i,j)表示区间[i,j]全部合成一个数,这个数是多少. 可以归纳证明[i,j] ...

  10. mysql general log日志

    注:应一直出现http://www.cnblogs.com/hwaggLee/p/6030765.html文章中的问题 故mysql general log日志.查看具体是什么命令导致的. 打开 ge ...