给定一组数字和一个运算符，编写一个Python函数来执行这些数字之间的运算。
num_list=[2,5,7,9]
operator="+"
以下是执行给定数字列表中的给定运算符的Python函数：

```python
def perform_operation(num_list, operator):
    if operator == "+":
        return sum(num_list)
    elif operator == "-":
        return num_list[0] - sum(num_list[1:])
    elif operator == "*":
        result = 1
        for num in num_list:
            result *= num
        return result
    elif operator == "/":
        result = num_list[0]
        for num in num_list[1:]:
            result /= num
        return result
    else:
        return "Invalid operator"
```

示例用法：

```python
num_list = [2, 5, 7, 9]
operator = "+"
result = perform_operation(num_list, operator)
print(result)  # 输出：23

operator = "-"
result = perform_operation(num_list, operator)
print(result)  # 输出：-19

operator = "*"
result = perform_operation(num_list, operator)
print(result)  # 输出：630

operator = "/"
result = perform_operation(num_list, operator)
print(result)  # 输出：0.0006349206349206349

operator = "%"
result = perform_operation(num_list, operator)
print(result)  # 输出：Invalid operator
```