我创建了一个简单的Python脚本,允许用户通过所有号码的电话邮件向手机发送短信。我编译成.exe所以我的朋友可以更容易访问它,但是在我编译之后我注意到.exe不接受Python解释器的输入方式。我使用了命令:
address = input("What is the address?")
以将响应作为字符串并将其用作稍后在脚本中显示的SMTP函数中的数据值:
import smtplib
server = smtplib.SMTP('smtp.gmail.com:587')
password = ["textFilter", "listCheck", "8*****ksd", "1231238dj", "312j38d", "12391jd", "1293ds", "12931d", "123c8we", "129ks9n2", "2139m2", "1s21231", "121i2m1", "16****on", "12983j", "231m8d9"]
spamActivate = True
messageSent = 0
modPat = 0
print "!Welcome to PySpammer v0.1 by CryptoFrost, all rights reserved to Damon %%%%% - 2014!\n\n"
print "To start using this program, you will need to know your target address. The address is an email linked to all" \
" phones. It uses the target number and the line extension. For example, a Verizon line would use [number]@vtext.com." \
" If you don't know the target address, simply have the target text an email that you have access to. Enter the" \
" email, check the received message, and use the sender's email that you will use for this program." \
" Here are a few known extensions:\n\n" \
"* Verizon - [number]@vtext.com\n" \
"* AT&T - [number]@txt.att.net\n" \
"* Straight-Talk - [number]@messaging.sprintpcs.com (Straight-Talk uses a few different addresses)\n" \
"* Sprint - [number]@messaging.sprintpcs.com (Yes, it's the same as ST)\n" \
"* Virgin Mobile - [number]@vmobl.com\n" \
"* T-Mobile - [number]@tmomail.net\n" \
"* Nextel - [number]@messaging.nextel.com\n\n" \
"Make sure to use the 10-digit number!"
address = input("What is the address?\n")
server.starttls()
server.login("thespamtasticbot@gmail.com",password[2])
msg = input("What is the message?\n")
while spamActivate:
server.sendmail("thespamtasticbot@gmail.com", address, msg)
messageSent = messageSent + 1
modPat = modPat + 1
print(messageSent, "total messages sent!")
# ["8******21@messaging.sprintpcs.com", "8********0@vtext.com", "******73@vtext.com", "*******08@vtext.com"]
当我将其编译为.exe并运行它时,我输入地址并获取:
我能够自己修复此问题的唯一方法是在地址周围输入引号......但我不想这样做(我不认为用户会这样做其一)。如何在输入之前格式化文本,以便将其用作字符串(无需将其格式化为程序内的字符串)?
答案 0 :(得分:0)
在Python 2.7.X字符串处理非常奇怪。使用python版本3.3.X很可能会修复它,但你必须改变一些语法。例如,print是3.3中的一个函数,所以你需要括号和额外的东西,你可以去http://www.python.org/download/获取最新版本的python。
这是我能想到的唯一解决方案。