cxwpf200 发表于 2018-8-14 11:13:11

python 模块包裹

arlenmbx@arlenmbx-ThinkPad-X130e:~$ su root  
密码:
  
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx# pythonPython 2.7.10 (default, Oct 14 2015, 16:09:02)
  
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
  
...
  
1
  
2
  
3
  
>>> print dic.keys()
  
['f1', 'f2', 'f3']>>> print dic.values()
  
>>> 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: No such file or directory: 'a.py'>>> f=open("a.txt","r+")
  
Traceback (most recent call last):
  
File "<stdin>", line 1, in <module>IOError: 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.pychmod: 无法访问"b.py": 没有那个文件或目录
  
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx# cd /home/arlenmbx/桌面root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# dira.pya.py~b.pyb.py~pro.txt
  
root@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# chmod 755 b.pyroot@arlenmbx-ThinkPad-X130e:/home/arlenmbx/桌面# ./b.pyhha
  
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/桌面# pythonPython 2.7.10 (default, Oct 14 2015, 16:09:02)
  
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
  
>>>
页: [1]
查看完整版本: python 模块包裹