易截截图软件、单文件、免安装、纯绿色、仅160KB

python中的exec 函数

      在项目里面一个解析文本的工具里面用到了这个命令来赋值,开始一直知道意思,呵呵 查了下,找到方法如下:
exec
语句用来执行储存在字符串或文件中的Python语句。例如,我们可以在运行时生成一个包含Python代码的字符串,然后使用
exec
语句执行这些语句。下面是一个简单的例子。
>>> exec 'print "Hello World"'
Hello World
t ='ggg'
exec('relist.append(%s)' % 't')
 relist = ['ggg'] 


相关文档:

python pyc

 什么是pyc文件
pyc是一种二进制文件,是由py文件经过编译后,生成的文件,是一种byte code,py文件变成pyc文件后,加载的速度有所提高,而且pyc是一种跨平台的字节码,是由python的虚拟机来执行的,这个是类似于JAVA或者.NET的虚拟机的概念。pyc的内容,是跟python的版本相关的,不同版本编译后的pyc文件是不同的,2 ......

用python的cmd模块写一个简单的shell

 from cmd import *
class MyShell(Cmd):
    def preloop(self):
        print "print this line before entering the loop"
            
    def postloop(self):
&nb ......

Installing Python 安装Python


   
You are here: Home ‣ Dive Into Python 3 ‣
Difficulty level: ♦♢♢♢♢
Installing Python 安装Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
— ancient Roman proverb
 
D ......

Python sqlite3和单元测试

 
import os
import unittest # 包含单元测试模块
import sqlite3 as sqlite # 包含sqlite3模块
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # 单元测试第一步: 由TestCase派生类
def setUp(self): # 单元测试环境配置
......

Python 线程操作

在python中如何创建一个线程对象
如果你要创建一个线程对象,很简单,只要你的类继承threading.Thread,然后在__init__里首先调用threading.Thread的__init__方法即可
import threading
class mythread(threading.Thread):
    def __init__(self, threadname):
      & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号