"The string supplied did not seem to be a phone number" 电话号码模块
"The string supplied did not seem to be a phone number" phonenumbers modual
我想弄清楚我做错了什么,我一直收到错误消息
The string supplied did not seem to be a phone number
我正在尝试制作一个小应用程序,它可以用 phone 数字做很多事情,比如给出位置和类似的东西。
代码如下:
import tkinter as tk
from tkinter import *
import phonenumbers
from phonenumbers import geocoder
from PIL import Image, ImageTk
from tkinter.font import Font
root = tk.Tk()
canvas =tk.Canvas(root, width=600, height=300, bg="#000000")
canvas.grid(columnspan=4, rowspan=4)
root.title("phOsint")
textbox = Entry(root, width=40,)
textbox.grid(column=1, row=2)
myFont = Font(
family="Magneto",
size=12,
slant="roman")
logo = Image.open("anonlogorm.png",).convert("RGB")
logo = ImageTk.PhotoImage(logo)
logo_label = tk.Label(image=logo, borderwidth=0)
logo_label.image = logo
logo_label.grid(column=1, row=0)
instructions = tk.Label(root, text="Enter in a phone number, let's see where it's located ;)", fg="light green", bg="black", font=myFont)
instructions.grid(columnspan=3, column=0, row=1)
def button_command():
phoneNumber = phonenumbers.parse(str(textbox))
phoneNumber.strip()
print(geocoder.description_for_number(phoneNumber, "en"))
browse_text = tk.StringVar()
browse_btn = tk.Button(root, textvariable=browse_text, command=button_command, bg="purple", fg="white", height=2, width=10, font=myFont)
browse_text.set("Show Me")
browse_btn.grid(column=1, row=3)
canvas =tk.Canvas(root, width=600, height=250, bg="#000000")
canvas.grid(columnspan=3,)
root.mainloop()
您已将 textbox
的名称传递给 button_command()
中的 phonenumbers.parse()
,请改用 textbox.get()
。
此外 phonenumbers.parse()
的结果不是字符串,您不能对其调用 strip()
:
def button_command():
phoneNumber = phonenumbers.parse(textbox.get().strip())
print(geocoder.description_for_number(phoneNumber, "en"))
我想弄清楚我做错了什么,我一直收到错误消息
The string supplied did not seem to be a phone number
我正在尝试制作一个小应用程序,它可以用 phone 数字做很多事情,比如给出位置和类似的东西。
代码如下:
import tkinter as tk
from tkinter import *
import phonenumbers
from phonenumbers import geocoder
from PIL import Image, ImageTk
from tkinter.font import Font
root = tk.Tk()
canvas =tk.Canvas(root, width=600, height=300, bg="#000000")
canvas.grid(columnspan=4, rowspan=4)
root.title("phOsint")
textbox = Entry(root, width=40,)
textbox.grid(column=1, row=2)
myFont = Font(
family="Magneto",
size=12,
slant="roman")
logo = Image.open("anonlogorm.png",).convert("RGB")
logo = ImageTk.PhotoImage(logo)
logo_label = tk.Label(image=logo, borderwidth=0)
logo_label.image = logo
logo_label.grid(column=1, row=0)
instructions = tk.Label(root, text="Enter in a phone number, let's see where it's located ;)", fg="light green", bg="black", font=myFont)
instructions.grid(columnspan=3, column=0, row=1)
def button_command():
phoneNumber = phonenumbers.parse(str(textbox))
phoneNumber.strip()
print(geocoder.description_for_number(phoneNumber, "en"))
browse_text = tk.StringVar()
browse_btn = tk.Button(root, textvariable=browse_text, command=button_command, bg="purple", fg="white", height=2, width=10, font=myFont)
browse_text.set("Show Me")
browse_btn.grid(column=1, row=3)
canvas =tk.Canvas(root, width=600, height=250, bg="#000000")
canvas.grid(columnspan=3,)
root.mainloop()
您已将 textbox
的名称传递给 button_command()
中的 phonenumbers.parse()
,请改用 textbox.get()
。
此外 phonenumbers.parse()
的结果不是字符串,您不能对其调用 strip()
:
def button_command():
phoneNumber = phonenumbers.parse(textbox.get().strip())
print(geocoder.description_for_number(phoneNumber, "en"))