【发布时间】:2020-02-08 16:20:51
【问题描述】:
我正在尝试制作一个 Python 脚本,将我连接到 VPN 服务器“号码”(将此号码作为变量)
我写道:
import os
VPNServer = 0
VPNServer += 1
os.system("networksetup -connectpppoeservice 'VPNServer {servernumber}'").format(servernumber = str(VPNServer))
print("→ Successfully connected to", "VPNServer", VPNServer)
但每次我尝试运行它时,控制台都会给我一个 AttributeError
AttributeError: 'int' object has no attribute 'format'
看不懂,因为我取了变量的字符串版本
如果有人可以帮忙,那就太棒了
我在 macOS 上使用 Python 3.8.1
【问题讨论】:
标签: python macos attributeerror os.system