Ejemplo n.º 1
0
import sys
from mymod import test, countChars, countLines
print test('test')
import mymod
print mymod.test('test')
Ejemplo n.º 2
0
def countLines(name):
    file = open(name, "r")
    data = file.readlines()
    n = len(data)
    file.close()
    return n


def countChars(name):
    file = open(name, "r")
    data = file.read()
    n = len(data)
    file.close()
    return n


def test(name):
    print "countLines:", countLines(name)
    print "countChars:", countChars(name)


if __name__ == "__main__":
    import mymod
    mymod.test("mymod.py")
Ejemplo n.º 3
0
#!/python
#-*- coding:utf8-*-

from mymod import test
#import mymod

if __name__ =='__main__':
	test('')
Ejemplo n.º 4
0
# Module "mymod" is fully imported
import mymod

print(mymod.countLines('mymod.py'))
print(mymod.countChars('mymod.py'))
print(mymod.test('mymod.py'))

# Functions are imported from the module
from mymod import countLines, countChars, test

print(countLines('mymod.py'))
print(countChars('mymod.py'))
print(test('mymod.py'))
import mymod

mymod.test('E:\Leanrning-Python-4th-solution\第五部分\TEST.txt')

from mymod import *

#都可以,然后我懒得打印,你自己慢慢打印
#上面路径问题,你自己根据你自己的本地地址调,具体怎么搞成通用的,我还不会,见谅
Ejemplo n.º 6
0
from mymod import test

if __name__ == '__main__':

    dante = "dante\ndante\n"
    test(dante)
Ejemplo n.º 7
0
import mymod

mymod.test('myclient1.py')
Ejemplo n.º 8
0
'''
myclient1.py - imports mymod.py and check its operation.
'''
from mymod import test, countChars, countChars1, countLines, countLines1
text = 'test.txt'
file = open(text)

print(test(text), test(file))
print(countChars(text), countChars1(file))
print(countLines(text), countLines1(file))

print('\nedited again version')