如何在python中从邮政编码中删除+4?
我有这样的数据
85001
52804-3233
Winston-Salem
我希望它变成
85001
52804
Winston-Salem
最佳答案
你可以尝试这样的事情:
for input in inputs:
if input[:5].isnumeric():
input = input[:5]
# Takes the first 5 characters from the string
只需去掉前 5 个位置的任何数字的前 5 个字符。
关于python - 删除邮政编码中的 -####,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6497293/