1. Tạo hàm:
def main_func(gotip):
gotip = gotip.replace(" ", "', '") #thay thế ký tự trong string
gotip = "'" + gotip + "'" #thêm ký tự đầu và cuối vào string
iptest = ''.join(ip) #chuyển thành tuple
return 'ok'
Từ 1 file .py khác gọi hàm này đơn giản như sau:
@CronManager.route('/create', methods=['POST'])
def create():
content = request.json
gotip = ' '.join(content['ipserver'])
print(gotip)
main_func(gotip) #gọi hàm main_func sau đó truyền biến gotip từ file này sang file .py có chứa hàm main_func
return gotip
Không có nhận xét nào:
Đăng nhận xét