Example #1
0
from main import foo

# 输出main-hello, world!

foo()
from test import foo

# 输出test-goodbye, world!
foo()
import main as m1
import test as m2

# main,hello, world!
m1.foo()
# test,goodbye, world!
m2.foo()
# 程序中调用的是最后导入的那个foo,因为后导入的foo覆盖了之前导入的foo
from main import foo
from test import foo

# 输出test-goodbye, world!
foo()
print('-' * 20, '求最大公约数和最小公倍数的函数', '-' * 20)


def gcd(x, y):
    """求最大公约数"""
    (x, y) = (y, x) if x > y else (x, y)
    for factor in range(x, 0, -1):
        if x % factor == 0 and y % factor == 0:
            return factor
Example #2
0
from test import foo

word = foo()
print(word['test'])

with open("../../../data/data.txt") as f:
    print("Okay")
Example #3
0
'''from PyQt4 import QtGui
import sys
import cv2

img = cv2.imread("/home/jason/Desktop/Programs/Crop_Features/lph4.png")
cv2.namedWindow('image',cv2.WINDOW_NORMAL)
cv2.imshow('image',img)
cv2.waitKey(0)
cv2.destroyAllWindows()'''

import test

test.foo()
print test.__SHADES__
Example #4
0
# 不管用什么样的编程语言来写代码,给变量、函数起名字都是一个让人头疼的问题,因为我们会遇到命名冲突这种尴尬的情况。最简单的场景就是在同一个.py文件中定义了两个同名的函数,
# 怎么解决命名冲突呢?答案其实很简单,Python中每个文件就代表了一个模块(module),
# 我们在不同的模块中可以有同名的函数,在使用函数的时候我们通过import关键字导入指定的模块再使用完全限定名的调用方式就可以区分到底要使用的是哪个模块中的foo函数
import m1
import test as t


def foo():
    print('main foo')


foo()

m1.foo()
t.foo()
 def testA(self):
   assert hw.foo() == 42
Example #6
0
import sys
import test
#from test import *

#print sys.argv[0]
print test.a
print test.foo()
import test

test.foo(1)
from test import foo

foo()
Example #9
0
import test

print(test.foo())
Example #10
0
def main():
    main_dict = init_dict()
    init_report(main_dict)
    response = None
    while response != '0':
        print('''
			1 - Проверить файл
			2 - Колличество номеров в файлах
			3 - Поиск по номеру
			4 - Отчеты по смс
			5 - Валидация имен
			6 - Добавить в feedback
			10 - Проверка категорий
			0 - Выйти''')
        response = input("Введите: ")
        if response == '1':
            response1(main_dict)

        if response == '2':
            response2(main_dict)

        if response == '3':
            response3(main_dict)

        if response == '4':
            response4(main_dict)

        if response == '5':
            import name
            name.main()

        if response == '6':
            add_feedback()

        if response == '10':
            response10(main_dict)

        if response == '7':
            dt = search_bulding_person(main_dict)
            print(len(dt))
            dt_deliv = {}
            for k in dt:
                for w in SITY_VAL:
                    if w.lower() == dt[k]['Город'].lower():
                        if dt[k]['Отправлено'] == 0 or dt[k][
                                'Отправлено'] == 1 and 'натяжн' not in dt[k][
                                    'Заголовок'].lower():
                            dt_deliv[k] = dt[k]
                            break
            print(len(dt_deliv))
            L_sort = []
            for k in dt_deliv:
                if dt_deliv[k]['Дата отправки'] == " ":
                    L_sort.append((k, 0))
                else:
                    c = dt_deliv[k]['Дата отправки'].split('.')
                    c.reverse()
                    c = ''.join(c)
                    L_sort.append((k, int(c)))
            L_sort.sort(key=lambda x: x[1])
            dt = {}
            for c in L_sort:
                dt[c[0]] = main_dict[c[0]]
            writin_new_exele('333.xlsx', dt)

        if response == '8':
            dt = validate_sity(main_dict)
            dt = validate_celling(dt)
            targ = {}
            for k in dt:
                if dt[k]['Отправлено'] == 0:
                    targ[k] = dt[k]
            writin_new_exele('123.xlsx', targ)
        if response == '11':
            import test
        if response == '12':
            test.foo()
Example #11
0
import pyximport; pyximport.install()
from test import foo

foo([b'hello', b'python', b'world'], [b'python', b'rules'])
Example #12
0
import test

a = test.foo()
#print a
Example #13
0
 def testA(self):
     assert hw.foo() == 42