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,14 +1,22 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding:utf-8-*-
import email
import hashlib
import imaplib
import json
import os.path
import requests
import sys
import time
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 hashlib
import imaplib
import json
import os.path
import requests
import sys
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 = {}

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
if __name__ == '__main__':
url = "https://smsapi.free-mobile.fr/sendmsg"
user= raw_input("Please enter usr: ")
print "you entered", user
password= raw_input("Please enter password: ")
print "you entered", password
msg = raw_input("Please enter msg: ")
print "you entered", msg
send(url, user, password, msg, 1)
user= input("Please enter usr: ")
print("you entered" + str(user))
password= input("Please enter password: ")
print("you entered"+ str(password))
msg = input("Please enter msg: ")
print("you entered"+ str(msg))
end = emails_sms_free.send(url, user, password, msg)