Skip to content

Instantly share code, notes, and snippets.

@kd0g
Last active July 5, 2022 08:50
Show Gist options
  • Save kd0g/87f629e29857865f7599049359a67e05 to your computer and use it in GitHub Desktop.
Save kd0g/87f629e29857865f7599049359a67e05 to your computer and use it in GitHub Desktop.
iOS padOS 에서 전화번호 바꾸기 스크립트(pythonista필요)
import contacts
ppls = contacts.get_all_people()
changed = False
for p in ppls:
for phone in p.phone:
y, pnum = phone
if pnum.startswith('010'):
pnum = pnum.replace('010', '+82 10', 1)
print(p.phone)
p.phone = [(y, pnum)]
changed = True
if changed:
contacts.save()
@PangMo5
Copy link

PangMo5 commented Jun 3, 2022

제가 파이썬이 주 언어가 아니라 잘 모르긴하는데
pnum = pnum.replace('010', '+82 10') 와 같이 replace하면 전체문자열에서 010이 모두 +82 10 으로 변경되어서
전화 번호가 01001001001 일경우 +82 10+82 10+82 1001 로 변경 되지 않을까여?
뒤에 count를 붙혀줘서 변경 할 횟수를 지정해야될듯합니다.

@kd0g
Copy link
Author

kd0g commented Jun 4, 2022

제가 파이썬이 주 언어가 아니라 잘 모르긴하는데
pnum = pnum.replace('010', '+82 10') 와 같이 replace하면 전체문자열에서 010이 모두 +82 10 으로 변경되어서
전화 번호가 01001001001 일경우 +82 10+82 10+82 1001 로 변경 되지 않을까여?
뒤에 count를 붙혀줘서 변경 할 횟수를 지정해야될듯합니다.

그러게요; 왠지 제가 갖고 있는 연락처 중에도 잘못 변환된 전화번호 있을 것 같습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment