python 2 and 3 compatible now

This commit is contained in:
MalcolmMielle 2014-11-04 13:45:57 +01:00
parent 0fe65f4b4d
commit 543ebfbb89
2 changed files with 28 additions and 17 deletions

View File

@ -1,6 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python
# -*- coding:utf-8-*- # -*- coding:utf-8-*-
from __future__ import print_function #print function python 2 and 3 compatible
try:
#import urllib.request as urllib_request #for python 3
import email import email
import hashlib import hashlib
import imaplib import imaplib
@ -9,6 +13,10 @@ import os.path
import requests import requests
import sys import sys
import time import time
except ImportError:
#import urllib2 as urllib_request # for python 2
import simplejson as json
print('Error importing lib as pyhton3, switching to python 2 libraries')
msg_ids = {} msg_ids = {}

19
test.py
View File

@ -1,12 +1,15 @@
#!/usr/bin/env python3 #!/usr/bin/env python
from builtins import input #pour rendre input python2 and 3 compatible
import emails_sms_free import emails_sms_free
if __name__ == '__main__': if __name__ == '__main__':
url = "https://smsapi.free-mobile.fr/sendmsg" url = "https://smsapi.free-mobile.fr/sendmsg"
user= raw_input("Please enter usr: ") user= input("Please enter usr: ")
print "you entered", user print("you entered" + str(user))
password= raw_input("Please enter password: ") password= input("Please enter password: ")
print "you entered", password print("you entered"+ str(password))
msg = raw_input("Please enter msg: ") msg = input("Please enter msg: ")
print "you entered", msg print("you entered"+ str(msg))
send(url, user, password, msg, 1) end = emails_sms_free.send(url, user, password, msg)