使用python开启简单的HTTP服务
1 2 3 4 5 6 7 8 9 10 11 12
| cd mydir
python -m SimpleHTTPServer 3000
python -m SimpleHTTPServer 3000 &
nohup python -m SimpleHTTPServer 3000 &
nohup python3 -m http.server 3000 &
|
SimpleHTTPServer有一个特性,如果待共享的目录下有index.html,那么index.html文件会被视为默认主页;如果不存在index.html文件,那么就会显示整个目录列表。
在哪个目录下启动,就会以当前目录为根目录展示列表
参考
python使用smtp发送邮件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import smtplib import sys from email.mime.text import MIMEText from email.header import Header
mail_host = "smtp.qq.com" mail_user = "发送方的qq邮箱" mail_pass = "smtp的授权码"
sender = '发送方的qq邮箱' reveiver = ['接收方邮箱']
message = MIMEText(sys.argv[1], 'plain', 'utf-8') message['From'] = Header('发送方名称<发送方邮箱>', 'utf-8') message['To'] = Header('接收方名称', 'utf-8')
subject = '邮件标题' message['Subject'] = Header(subject, 'utf-8')
try: smtpObj = smtplib.SMTP() smtpObj.connect(mail_host, 587) smtpObj.login(mail_user, mail_pass) smtpObj.sendmail(sender, reveiver, message.as_string()) except Exception as e: print(e)
|
1 2 3 4
| python3 sendMail.py 我想发送一些内容
python3 sendMail.py
|
参考
python执行某模块
当同一电脑中安装了多个版本的python,或者多个不同用途的python,在不同的python环境下又有不同的属于该python的模块,那么就需要指定用哪个python的哪个模块。
1 2 3 4 5 6 7 8
|
path/to/A/python -m pip install requests
path/to/B/python -m waitress --listen=0.0.0.0:3002 app:app
|