当前位置: 首页 > news >正文

python 模块包裹

复制代码
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
>>> 
复制代码

转载于:https://www.cnblogs.com/wangsicongde/p/7599136.html

相关文章:

  • no.6 字符串和格式化输入/输出02
  • 从零开始编写自己的C#框架(18)——Web层后端权限模块——菜单管理
  • jquery操作字符串常用方法总结及工作代码
  • retrofit post请求多文件,partMap用法
  • 【转载】Etcd+Confd实现Nginx配置文件自动管理
  • C#编程(五十五)----------HashSet和SortedSet
  • 云非万能!云计算不能解决的三大问题
  • maven打包加速(转) (开启多线程,之前发现只占用一核CPU100%,其他CPU闲置的情况)...
  • Android Studio 入门级教程
  • lua中实现倒计时
  • 条款7:为多态基类声明virtual析构函数
  • Linux下rootkit后门检测工具chkrootkit
  • 人们应将公共云与私有云的辩论抛之脑后
  • 毕业两年的程序猿经验小结
  • 数据库 之 SQL语句构成和分类
  • [deviceone开发]-do_Webview的基本示例
  • 《Javascript高级程序设计 (第三版)》第五章 引用类型
  • 【跃迁之路】【733天】程序员高效学习方法论探索系列(实验阶段490-2019.2.23)...
  • Asm.js的简单介绍
  • Bytom交易说明(账户管理模式)
  • codis proxy处理流程
  • DOM的那些事
  • HTTP 简介
  • Java超时控制的实现
  • java中的hashCode
  • niucms就是以城市为分割单位,在上面 小区/乡村/同城论坛+58+团购
  • OpenStack安装流程(juno版)- 添加网络服务(neutron)- controller节点
  • Python实现BT种子转化为磁力链接【实战】
  • 阿里云ubuntu14.04 Nginx反向代理Nodejs
  • 从地狱到天堂,Node 回调向 async/await 转变
  • 从零搭建Koa2 Server
  • 开年巨制!千人千面回放技术让你“看到”Flutter用户侧问题
  • 世界上最简单的无等待算法(getAndIncrement)
  • 通过几道题目学习二叉搜索树
  • 移动端 h5开发相关内容总结(三)
  • 由插件封装引出的一丢丢思考
  • 【干货分享】dos命令大全
  • ​​快速排序(四)——挖坑法,前后指针法与非递归
  • (android 地图实战开发)3 在地图上显示当前位置和自定义银行位置
  • (C++)栈的链式存储结构(出栈、入栈、判空、遍历、销毁)(数据结构与算法)
  • (Java)【深基9.例1】选举学生会
  • (附源码)node.js知识分享网站 毕业设计 202038
  • (附源码)spring boot北京冬奥会志愿者报名系统 毕业设计 150947
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (附源码)ssm基于jsp的在线点餐系统 毕业设计 111016
  • (附源码)ssm跨平台教学系统 毕业设计 280843
  • (深入.Net平台的软件系统分层开发).第一章.上机练习.20170424
  • (原创)Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly DetectionRecommender Systems...
  • (转)人的集合论——移山之道
  • .apk 成为历史!
  • .cn根服务器被攻击之后
  • .gitignore文件设置了忽略但不生效
  • .net core 源码_ASP.NET Core之Identity源码学习
  • .NET 药厂业务系统 CPU爆高分析
  • .NET 中使用 TaskCompletionSource 作为线程同步互斥或异步操作的事件