コード例 #1
0
ファイル: test2.py プロジェクト: jayashree8/Python_guide
import test1

print("top-level in test2.py")

test1.func()

if __name__ == "__main__":
    print("test2.py is being run directly")
else:
    print("test2.py is being imported into another module")
    
    
    
コード例 #2
0
ファイル: testYAML.py プロジェクト: iceandrise/ISP-lab
    def test_yaml_func(self):

        yaml_func = serializer.dumps(test1.func, 'yaml')
        des_func = serializer.loads(yaml_func, 'yaml')

        self.assertEqual(test1.func(2), des_func(2))
コード例 #3
0
ファイル: hello.py プロジェクト: yang00-74/python_demo
# c="".join([a,b])

print content[0:20].decode('utf-8').encode('gbk') #substring 0-20
print len(dcontent)
"""
#find() the string start index 
#use index()will throw exception if the string not exist
"""
print content.find('this') 
r = open('test1.txt','w')#write file
#r.write(content[20:40])
#sys.stdout = r
#help(time)
r.close();

li = [x for x in xrange(1,10)] #create a list rang(1,10)
n=(4,9) #小括号为元组,不可变
m=[1,8,6] #中括号为列表,可变
p={'yangye':2} #大括号为字典,无序,可变 p=dict('yangye'=2)
print li
p['yangye'] ='bybe'
print p
print set("yangye") #set集合无序可进行操作,frozenset不可操作

import test1 #导入自定义文件
print test1.func(1,2,3,6,1,2,{4:5,6:7},k=12,p=25)

# import model.testmodel as model
# from model import testmodel
from model import * #该用法需要配置模块下面的__init__.py文件的__all__=[]
print testmodel.getName('yangye')
コード例 #4
0
ファイル: testJSON.py プロジェクト: iceandrise/ISP-lab
    def test_json_func(self):

        json_func = serializer.dumps(test1.func, 'json')
        des_func = serializer.loads(json_func, 'json')

        self.assertEqual(test1.func(2), des_func(2))
コード例 #5
0
ファイル: testPICKLE.py プロジェクト: iceandrise/ISP-lab
    def test_pickle_func(self):

        pickle_func = serializer.dumps(test1.func, 'pickle')
        des_func = serializer.loads(pickle_func, 'pickle')

        self.assertEqual(test1.func(2), des_func(2))
コード例 #6
0
ファイル: main.py プロジェクト: Christopher-Bradshaw/learning
from test1 import func
import pyximport
pyximport.install()
import test2

print(func())

print(test2.__file__)
print(test2.func2())