使用sys时总是只显示[0]也就是py文件名,跟随的py文件后的参数无法传入,经过百度,发现需要在py文件名前加上python才能成功传入参数
//cmd命令
...Desktop>python CTpachogn.py CT56 1 8039593331
import requests import sys url = 'http://www.700156.com/CT/Order/DataQueryNew' def query(companyid, type, no): d = {'companyid': companyid, 'type': type, 'no': no} r = requests.post(url, data=d) result = r.json() return result def text(companyid, type, no): d = {'companyid': companyid, 'type': type, 'no': no} r = requests.post(url, data=d) result = r.json() return result if __name__ == '__main__': # print(text("CT56", 1, 8039593331)) # print(text("CT56", 1, 8039593331)["Success"]) if len(sys.argv) < 1: print('No action specified.') # sys.exit() else: companyid = sys.argv[0] type = sys.argv[1] no = sys.argv[2] query(companyid, type, no) print(query(companyid, type, no))