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] Gray Code 格雷码

    The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...

  2. Goodbye 2016 总结与展望

    今天居然是2016年的最后一天了,写点什么回忆吧. 2016开始的时候我刚拿到普及组一等奖,还只是压线,水平很差.学校并不知道这有多差,于是狠狠宣传这所谓的"光荣事迹".那段时间我 ...

  3. 俄罗斯方块C#版

    using System; using System.Windows.Forms; using System.Drawing; using System.Media; class me : Form ...

  4. Bootstap datetimepicker报错TypeError: intermediate value

    Bootstrap datetimepicker有多个版本,官方的链接中,只是datepicker,没有时间的选择,原版的datetimepicker也不再更新,不能用新版的jquery.现在http ...

  5. 篇二:MySQL存储过程

    目的:写一个存储过程,往数据库中插入几百条数据,作为识别码给别人用(这里我觉得和验证码的功能相似) BEGIN ); ); ) ; ); ); ; ; while count <= insert ...

  6. [翻译] V8引擎的解析

    原文:Parsing in V8 explained 本文档介绍了 V8 引擎是如何解析 JavaScript 源代码的,以及我们将改进它的计划. 动机 我们有个解析器和一个更快的预解析器(~2x), ...

  7. Java集合框架List,Map,Set等全面介绍

    Java集合框架的基本接口/类层次结构: java.util.Collection [I]+--java.util.List [I]   +--java.util.ArrayList [C]   +- ...

  8. WebForm业务系列-会员功能

    用了这么久的webform,还记得刚开始根本不知道程序要写成什么样,只知道功能实现了就行,有很多现实的问题都没考虑到.所以程序改了又改,最后连自己做的什么都不知道了.所以,现在来总结一下. 会员功能 ...

  9. Asp.net MVC的ViewData与ViewBag以及TemplateData的使用与区别

    ViewData ViewBag 它是Key/Value字典集合 它是dynamic类型对像 从Asp.net MVC 1 就有了 ASP.NET MVC3 才有 基于Asp.net 3.5 fram ...

  10. 用rose画UML图(用例图,活动图)

    用rose画UML图(用例图,活动图) 首先,安装rose2003,电脑从win8升到win10以后,发现win10并不支持rose2003的安装,换了rose2007以后,发现也不可以. 解决途径: ...